Skip to content
Français

Intermittent demand

  • Lesson 19
  • 35 min
  • Module 6: Hard series and many series

Where we are

Our hierarchy adds up now. At its bottom, some products sell once a week or once a month, and most days are zero. In this lesson, we see why the usual forecasts and measures fail on slow sellers, and we use Croston, SBA and TSB.

Plays from YouTube. Nothing loads from YouTube until you press play. Privacy

What you will be able to do

Forecast products that sell on only a few days, and choose the forecast with a measure that fits them. On a slow seller, most days are zero. The usual error measures then prefer a forecast of zero, which orders nothing. Croston’s method, and its variants SBA and TSB, forecast how much a sale is and how often it comes.

NotebookDo this lesson in a notebookColab · Kaggle · GitHub

The notebook has every code cell, task and check of this lesson. It works Croston’s method by hand and finds Larkfield’s 140 slow series. Then it backtests six methods on them and shows why “always 0” wins on MASE. Its setup cells install the packages and download the Larkfield data, so it needs no local setup. About 35 minutes.

Colab and Kaggle open your own copy. They need a free Google or Kaggle account. Stuck? See the solution notebook.

Before you startWhat to know and to have readyAbout 35 minutes

What you need to know

What you need on your computer

Nothing: the notebook runs in Colab or Kaggle.

Tested with Python 3.12, pandas 2.3.3 and statsforecast 2.1.1, in Jupyter on macOS.

You keep a spare house key for visitors. A visitor comes about once a month, and nobody can tell you which day. How many keys do you need next week?

“Zero” is right on most days, so it sounds like a good forecast. But if you plan for zero, you have no key on the day a visitor comes. A better answer has two parts: how often visitors come (about every 30 days) and how many come at once (usually one). Then you can plan: one key is enough.

Larkfield has many products like this: a few units on a few days, with long gaps between.

Priya looks at the bottom of the hierarchy: one product in one region. She keeps the series that were on sale for the whole history and have 70% or more days with no sale:

140 slow series | mean share of zero days: 0.902
vacuum bags P170, days with a sale: {'north': 12, 'south': 5, 'coast': 11}

On average, 9 days in 10 have no sale. The vacuum bags sell about once a month. Demand like this, with many zero days and sales at irregular times, is called intermittent demand. The products are slow sellers.

Priya runs the course backtest (13 cut-offs, or origins, 14 days each) on the 140 series. One of her methods is a joke: it always forecasts 0.

method MASE WAPE % bias % cost $
always 0 0.599 100.0 -100.0 4371
seasonal naive 1.012 156.7 -4.0 2885
Croston 1.091 165.5 4.6 3733
SBA 1.066 162.2 -0.6 3679
TSB 1.007 152.9 -3.1 3193
ADIDA 1.004 151.6 -4.4 2911

“Always 0” has the best MASE by far. Only “always 0” gets below 1, “better than the seasonal naive forecast”. Yet it orders nothing, so Kenji loses every sale: its cost is the highest in the table, 4,371 dollars per order cycle. The cost uses the course’s assumptions: a lost sale costs 35% of the price, and a left-over unit 25%.

By MASE, the forecast that always says 0 (Zero) is the best of all methods on the 140 slow series. S-naive is the seasonal naive forecast.
Text description of the chart

A column chart of MASE on 140 slow series. Always 0: 0.599, the lowest. Seasonal naive: 1.012. ADIDA: 1.004. ETS: 1.009. TSB: 1.007. SBA: 1.066. Croston: 1.091.

By the cost of the stock order, the same forecast is the worst: it orders nothing and loses every sale. The seasonal naive forecast costs least.
Text description of the chart

A column chart of the cost of the 14-day stock order, per order cycle, on 140 slow series. Always 0: 4,371 dollars, the highest. Seasonal naive: 2,885, the lowest. ADIDA: 2,911. ETS: 2,950. TSB: 3,193. SBA: 3,679. Croston: 3,733.

MASE divides the mean absolute error by a scale. Look at one day with no sale. A forecast of 0 has an error of 0. A forecast of 0.15 has an error of 0.15. In the backtest, 90.2% of the forecast days have no sale:

forecast days: 25480 | days with no sale: 22993 (90.2%) | units sold: 3120
always 0 mean absolute error per day: 0.1224
Croston mean absolute error per day: 0.2026

The absolute error rewards the forecast that is right on a typical day, and a slow seller’s typical day has no sale. In statistics words: the absolute error is smallest at the median, and the median of a slow seller is 0. WAPE fails in another way: “always 0” misses every unit, so its WAPE is exactly 100%, while the others are above 150%. MAPE cannot even be computed, because it divides by the sales of zero days.

A stock order needs the total of the next 14 days, not the typical day. A forecast that is right on average, with a bias near 0, adds up to the right total.

In 1972, J. D. Croston proposed to forecast a slow seller as two smaller series, like the spare key:

  • the demand size: the units sold on each day with a sale;
  • the interval: the days from one sale to the next.

Croston smooths each one with simple exponential smoothing. The newest value gets a weight of 0.1, and the old level keeps 0.9. Then he divides the size by the interval. Units per sale divided by days per sale gives units per day. The forecast is this average rate, the same for every future day.

Fourteen day squares with sales of 2 on day 3, 1 on day 7 and 3 on day 10, zero on the others. Brackets show intervals of 3, 4 and 3 days. Two boxes show the smoothed size (2.00, 1.90, 2.01) and interval (3.00, 3.10, 3.09). A green box gives the forecast 2.01 ÷ 3.09 = 0.65 a day.
Croston splits the series into demand sizes (2, 1, 3) and intervals (3, 4, 3), smooths each, and divides: 0.65 units a day. The four zero days at the end do not change it.
Text description of the diagram

The diagram shows 14 day squares. Day 3 sold 2 units, day 7 sold 1, day 10 sold 3, and the other 11 days sold 0. Brackets under the squares show the intervals: 3 days to the first sale (counted from the start), 4 days to the second and 3 days to the third. Days 11 to 14 have no sale yet. The demand sizes 2, 1 and 3 smooth to 2.00, then 1.90, then 2.01. The intervals 3, 4 and 3 smooth to 3.00, then 3.10, then 3.09. The forecast per day is 2.01 ÷ 3.09 = 0.65 units, the same for every future day. Croston does not change on days 11 to 14. TSB lowers its forecast to 0.29 a day.

Every step, with a weight of 0.1:

Sale Units Interval Smoothed size Smoothed interval
Day 3 2 3 2.00 (the first value) 3.00 (the first value)
Day 7 1 4 0.1 × 1 + 0.9 × 2.00 = 1.90 0.1 × 4 + 0.9 × 3.00 = 3.10
Day 10 3 3 0.1 × 3 + 0.9 × 1.90 = 2.01 0.1 × 3 + 0.9 × 3.10 = 3.09

Forecast: 2.01 ÷ 3.09 = 0.65 units a day, or about 9 units in 14 days. statsforecast’s CrostonClassic gives the same number:

size 2.01, interval 3.09, forecast 0.650 a day
CrostonClassic CrostonSBA TSB
0.65 0.618 0.291

Croston has two known weaknesses. Each one has a named repair.

  • It is a little too high on average. Dividing two smoothed numbers gives a result that is biased upward. Syntetos and Boylan showed this, and their repair, SBA, multiplies Croston’s forecast by 0.95 here: 0.65 × 0.95 = 0.618.
  • It changes only on a day with a sale. After the last sale, the four zero days do not count. If a product stops selling, Croston keeps forecasting the old rate for ever. TSB (Teunter, Syntetos and Babai) smooths a different pair: the size, and the chance of a sale on any day. The chance goes down on every zero day, so TSB lowers its forecast to 0.291.

A third method, ADIDA, adds the days up into blocks as long as the average interval, so that each block is rarely zero. It forecasts the blocks and spreads the result evenly over the days.

The frying pan P120 in the north is a typical slow seller. Up to the last cut-off, 15 March 2026, it sold 81 units on 75 of its 714 days. So 89.5% of its days have no sale.

  • Units sold per day
  • Croston's forecast per day
  • TSB forecast, next 14 days
  • Sold in the next 14 days
The frying pan sells 1 or 2 units on a few days. Croston's forecast moves only on those days, from 0.089 to 0.146 a day. After 15 March, Croston forecasts 2.05 units in 14 days, TSB 0.80; the pan sold 1.
Text description of the chart

The chart shows 16 weeks of the frying pan’s daily sales in the north, from 24 November 2025 to 15 March 2026. On 16 days the pan sold 1 or 2 units; the other days are 0. Croston’s forecast is a step line that changes only on a sale day. It rises from 0.089 a day to 0.146 after the last sale, on 28 February. For the 14 days after 15 March, Croston forecasts 0.146 a day and TSB 0.057 a day. In those 14 days, the pan sold 1 unit, on one day.

The next picture zooms into the last six weeks. It shows the intervals that Croston sees, and its two smoothed numbers after each sale.

Six weeks of day squares for the frying pan in the north, with six sale days of one unit each. Blue brackets show intervals of 3, 4, 4, 7 and 3 days, then 15 days with no sale. A table gives, for each sale, the interval, the smoothed size, the smoothed interval and the forecast per day, ending at 1.07, 7.32 and 0.146.
Croston's demand size (1.07 units) and interval (7.32 days) for the frying pan: 0.146 units a day. The 15 days with no sale before the cut-off do not change it; TSB, which counts them, forecasts 0.057.
Text description of the diagram

The diagram shows the frying pan’s last 42 days before 15 March 2026. Six days have a sale of 1 unit: 7, 10, 14, 18, 25 and 28 February. Then 15 days have no sale. A table lists each sale with the days since the last sale, the smoothed size, the smoothed interval and the forecast per day: 7 February: 15, 1.12, 9.45, 0.118. 10 February: 3, 1.11, 8.80, 0.126. 14 February: 4, 1.10, 8.32, 0.132. 18 February: 4, 1.09, 7.89, 0.138. 25 February: 7, 1.08, 7.80, 0.138. 28 February: 3, 1.07, 7.32, 0.146. TSB forecasts 0.057 a day, 0.80 units in 14 days.

Kenji orders whole units. The course’s stock cost rounds the 14-day total up: Croston orders 3 frying pans, TSB 1, and “always 0” orders none. The pan sold 1.

Here is the backtest on all 140 slow series, with ETS and the naive forecast (yesterday’s sales) from the course’s measurement:

Method MASE WAPE % bias % RMSE cost $
Always 0 0.599 100.0 −100.0 0.440 4,371
Seasonal naive 1.012 156.7 −4.0 0.534 2,885
ADIDA 1.004 151.6 −4.4 0.392 2,911
ETS 1.009 150.9 −4.6 0.393 2,950
TSB 1.007 152.9 −3.1 0.397 3,193
SBA 1.066 162.2 −0.6 0.406 3,679
Croston 1.091 165.5 +4.6 0.406 3,733
Naive 1.063 169.6 +18.9 0.555 5,238

Read it in three steps:

  1. Croston is biased high, as expected: +4.6%. SBA’s 0.95 brings it to −0.6%, the best bias of all.
  2. The squared error does not prefer zero. RMSE squares each error before averaging. So it is smallest for a forecast that is right on average (the mean), not on a typical day. By RMSE, ADIDA and ETS are best (0.392 and 0.393), and “always 0” is far behind.
  3. The cheapest order is not from a slow-seller method. The seasonal naive forecast only repeats last week’s sales, and it costs least (2,885 dollars), just ahead of ADIDA and ETS. Always keep a simple method in the table.

The honest result: on Larkfield’s slow sellers, Croston, SBA and TSB do not beat simpler methods on cost. The lesson is about the measure more than the method.

For slow sellers:

  • Do not choose by MASE, MAE or WAPE alone. They prefer zero or punish every forecast that is not zero.
  • Do look at the bias. A stock order adds up 14 days. A forecast that is right on average gives the right total.
  • Choose by the cost of the decision when you have one. Here: the stock order with the course’s costs.
  • Use RMSE (or a scaled version of it, RMSSE) when you need one error number. It does not reward zero.

When to use Croston and its family, and what it costs

Section titled “When to use Croston and its family, and what it costs”

Use them when most days are zero and the sales come at irregular times: spare parts, slow home products, rare medicines. They are fast: 140 series and 13 cut-offs took less than 0.1 second.

Do not use them when the zeros have a pattern. A seasonal product with zero sales every winter is not intermittent: its zeros are predictable. Do not use them either when the zeros come from stock-outs. Then the demand was there, and the sales hide it (Clean without hiding demand).

They cost little to run, but their forecast is a rate, never “1 unit on Thursday”: Kenji gets an order size, not a sale date.

Common mistake

The best score, the worst order

Symptom: Tomás sorts the slow-seller table by MASE and suggests “always 0” for all 140 series: “It is the best model, and it is free.” The next order cycle, Kenji orders no slow sellers at all.

Cause: with 90.2% zero days, the absolute error is smallest at zero. MASE, built on the absolute error, rewards a forecast that never orders.

Fix: choose slow-seller forecasts by the cost of the order, and check the bias and RMSE. “Always 0” cost 4,371 dollars per order cycle in lost sales, against 2,885 for the seasonal naive order.

Consequence in AI work: a metric that does not match the decision picks a model that looks best and does the most damage. Customers find the slow products always out of stock.

Guided practice: slow sellers in the notebook

Section titled “Guided practice: slow sellers in the notebook”
  1. Open the notebook from the box Do this lesson in a notebook at the top of this page.
  2. Run the setup cells. The data cell ends with the Ready: line.
  3. In section 1, predict if Croston’s forecast is above or below 0.6. Then run the cell. You see forecast 0.650 a day.
  4. In section 2, run the cell. You see 140 slow series.
  5. In section 3, predict which method gets the best MASE and the lowest cost. Run the backtest. You see the six-row table.
  6. In section 4, run the cell. You see 22993 days with no sale.
  7. In section 5, write your answer in the Your turn cell, then run the check cell.

Before you run it, predict: the frying pan sold about 1 unit every week or so. Will Croston’s forecast be closer to 0.1 or to 0.5 units a day? In the notebook, section 5, apply the croston() function of section 1 to the frying pan’s sales up to ORIGINS[-1]. Put the forecast per day, rounded to 3 decimals, in pan_per_day.

Show the answer
pan = slow[(slow["unique_id"] == "P120/north") & (slow["ds"] <= ORIGINS[-1])]["y"]
size, interval, per_day = croston(pan)
print(f"size {size:.3f}, interval {interval:.3f}")
pan_per_day = round(float(per_day), 3)
print(pan_per_day, "a day,", round(14 * per_day, 2), "units in 14 days")
size 1.071, interval 7.321
0.146 a day, 2.05 units in 14 days

About 1.07 units every 7.32 days: 0.146 a day. The plain average interval over the whole history is 9.32 days. The smoothed one is shorter, because the pan sold more often in the last weeks.

Check your understanding

Explain with Larkfield's numbers why a forecast of always 0 wins on MASE for slow sellers, and why Kenji should not use it.

Show the answer

On the 140 slow series, 90.2% of the forecast days have no sale. On those days, a forecast of 0 has no error, so its mean absolute error (0.1224) is lower than Croston’s (0.2026). MASE is built on the absolute error, so “always 0” gets the best MASE, 0.599. But it orders nothing: its bias is −100% and it loses every sale. Its stock cost is 4,371 dollars per order cycle, the highest of the slow-seller methods; the seasonal naive order cost 2,885.

Check your understanding

A product sold 0, 3, 0, 0, 1, 0 units on six days. Compute Croston's forecast per day with a weight of 0.1, and say what TSB does differently.

Show the answer

The sales are on day 2 (3 units) and day 5 (1 unit). Sizes: 3, 1. Intervals: 2 (from the start), 3. Smoothed size: 3, then 0.1 × 1 + 0.9 × 3 = 2.8. Smoothed interval: 2, then 0.1 × 3 + 0.9 × 2 = 2.1. Forecast: 2.8 ÷ 2.1 = 1.33 units a day. Croston ignores the zero day 6. TSB smooths the chance of a sale on every day, so day 6 lowers its forecast.

Check your understanding

Predict: Grace counts the help-desk tickets about one rare product, a gas grill, per day. Most days have none. Which error measure would you use to choose its forecast, and why?

Show the answer

Not MASE, MAE or WAPE alone: with mostly zero days, they reward a forecast of zero, and Grace would plan no time for these tickets. Use the cost of the decision if there is one, for example the cost of an hour short or an extra agent hour. Otherwise use RMSE, which is smallest for a forecast that is right on average, and check the bias. A forecast with a bias near 0 adds up to the right number of tickets over the week.

Recap

  • Intermittent demand: most days are zero. Larkfield has 140 slow series with 90.2% zero days on average.
  • The absolute error is smallest at the median, which is 0 for a slow seller. So “always 0” has the best MASE (0.599) and the worst cost (4,371 dollars per order cycle).
  • Croston forecasts the demand size and the interval, and divides them. The frying pan sells 1.07 units every 7.32 days, 0.146 a day.
  • SBA removes Croston’s upward bias (×0.95); TSB lowers its forecast on zero days; ADIDA forecasts blocks of days.
  • Choose slow-seller forecasts by cost, bias and RMSE. On Larkfield, the seasonal naive order cost least (2,885), then ADIDA and ETS.

Slow sellers have a long history with few sales. A new product has the opposite problem: a short history. Next, you forecast products with only six weeks of sales, from their category and from a global model.

Next: New products with no history