Decision Atlas
DEMDemandStop 5 of 12
  1. Forecasting fundamentals
  2. Demand patterns & classification
  3. Exponential smoothing & ETS
  4. Intermittent demand: Croston, SBA, TSB
  5. ML & global forecasting models
  6. Forecast accuracy & bias
  7. Probabilistic forecasting
  8. Hierarchical forecasting
  9. Promotions, cannibalization & halo
  10. New products & phase-outs
  11. Demand sensing & shaping
  12. Consensus forecasting & FVA

ML & global forecasting models

Gradient boosting, deep learning and foundation models that learn across thousands of series at once, and when they actually win.

3 min gist, 11 min in full Draft, review pending

Read atChange any time

From one model per item to one model that learns across all items.

Classic methods fit one model per item: thousands of SKUs means thousands of small models, each learning only from its own short history. A global model flips this. One model learns from all items together, so a new or sparse item can borrow patterns from similar ones.

The most common version in practice is gradient boosting (LightGBM, XGBoost). You turn forecasting into a table of features and let the model learn how they relate to sales:

  • history features: sales last week, the same week last year, rolling averages
  • calendar features: day of week, festivals, paydays, school holidays
  • business features: price, discount depth, promotion flags, display space

That is why these models shine when demand is driven by things you can see coming, such as promotions and price changes. In the Walmart-based M5 competition (2020), most of the top entries were LightGBM-based. In the earlier M4 competition on mostly business and economic series without those drivers, combinations of statistical methods and a hybrid of exponential smoothing with a neural network did best.

Deep learning models such as DeepAR, N-BEATS and the Temporal Fusion Transformer push the global idea further, and newer foundation models are pre-trained on huge collections of time series so they can forecast a new series with little or no training.

They have limits. Tree models don’t extrapolate trends beyond what they’ve seen, every model needs clean data and careful backtesting, and on stable items without drivers a well-tuned exponential smoothing model is very hard to beat.

Words to use

Global model
One model trained across many series, sharing patterns between them.
Feature engineering
Turning history, calendar and business drivers into model inputs.
Foundation model
A model pre-trained on very many time series that can forecast new ones with little training.

How a global model is built: the training table, avoiding leakage, the loss function and honest testing.

Step 1: turn history into a table

Each row is one item, at one location, in one period. The target is the sales you want to predict; the columns are features known at the moment the forecast is made.

Worked example: a shampoo's training rows
WeekSales (target)Sales 1 week beforeSame week last yearPrice (₹)On promotionFestival week
401,1509801,020199NoNo
411,8901,1501,060149YesNo
421,4201,8901,300199NoYes

Stack rows like these for thousands of items, and one model can learn how much a ₹50 price cut lifts sales, how festivals add to the base and how sales dip after a promotion, from every item at once.

Typical feature groups: recent sales and rolling averages, the same period last year, calendar effects (day of week, month, festivals, paydays), price and promotion plans, product attributes (category, brand, pack size) and location attributes.

Step 2: avoid leakage

Leakage means letting the model see information it won’t have when forecasting for real, which makes test results look far better than reality. The two classic forms:

  • Horizon leakage: if you forecast four weeks ahead, “sales one week before” isn’t known yet for weeks two to four. Either use only lags of at least four weeks, or forecast one week at a time and feed the predictions back in (recursive forecasting).
  • Future information: a promotion that happened but wasn’t planned when the forecast was made, or a rolling average that includes the week being predicted.

Step 3: choose what the model minimizes

  • Squared error targets the mean, the usual choice for replenishment.
  • For sales counts with many zeros, a Tweedie or Poisson loss fits the data better.
  • For a P90 forecast, quantile (pinball) loss trains the model to hit that quantile directly.

Step 4: test it like a forecast

Split by time, never at random: train on the past, test on the future, and roll the cut-off forward several times (rolling-origin backtesting). Compare against strong simple baselines, such as seasonal naive and ETS, at the horizon the decision uses, and check bias by segment, not only overall accuracy.

Why global models work, what the M5 competition taught, deep learning and foundation models, and what breaks in production.

Why one model for many items works

A single item may have only two years of noisy history, but ten thousand items together hold millions of observations of how prices, promotions, seasons and holidays move demand. A global model learns those shared effects once and applies them everywhere, including to new or sparse items. To make items comparable, sales are often scaled per item (for example, divided by each item’s average) before training.

Lessons from the M5 competition

The M5 competition used hierarchical Walmart sales data with prices, promotions and calendar events. The organizers’ findings (Makridakis and colleagues, 2022) included:

  • Gradient-boosted trees trained across many series dominated the top places.
  • Explanatory variables such as prices and events improved accuracy.
  • Combining several models, trained on different subsets or with different settings, beat single models.
  • Validation that mimicked the real forecasting setup was essential.

Deep learning and foundation models

Neural approaches such as DeepAR (probabilistic forecasts from a recurrent network), N-BEATS and the Temporal Fusion Transformer also learn across series and can output full distributions. Foundation models for time series are pre-trained on very large collections of series and can forecast a new one with little or no training. They are promising for cold starts and quick prototypes, but on rich retail data with known drivers, well-tuned tree models remain hard to beat, so test before switching.

What breaks in production

  • Trends: trees predict within the range they have seen, so a fast-growing item gets flattened. Model the change rather than the level, or blend with a method that handles trend.
  • Stability: ML forecasts can jump from week to week and make plans nervous. Smooth the output or limit near-term changes.
  • Explainability: planners trust what they understand. Feature-importance tools, such as SHAP values, help explain why a forecast moved.
  • Maintenance: feature pipelines, retraining, monitoring and data drift take real effort. A model that is slightly more accurate but breaks every month may not be worth it.

Interview kit

Practise it out loud

Answer each question yourself before opening the model answer.

Say it in 30 seconds

Forecasting has moved from one statistical model per SKU to global models that learn across many series. Gradient-boosted trees like LightGBM use history, calendar, price and promotion features, which is why they dominated the M5 retail competition. On series without such drivers, as in M4, statistical methods and combinations did best. So I’d choose by context: global ML when there are many related series and real drivers, classical methods as a strong baseline, and often an ensemble of both.

When would you not use machine learning for forecasting?

When there are few series, short histories and no meaningful drivers, a tuned statistical model is usually as accurate, simpler to explain and cheaper to maintain. ML also adds data and monitoring work, so it has to beat the baseline in backtests to earn its place.

Why do tree-based models struggle with trends?

Trees predict by averaging values they saw in training, so they can’t produce numbers beyond that range. A growing product’s forecast flattens at the highest level seen. Common fixes are differencing or detrending the target, or combining the trees with a statistical trend model.

Connected stops

Where this idea feeds in, or gets its inputs from.

Sources and further reading

  1. Makridakis, S., Spiliotis, E. & Assimakopoulos, V. (2022). M5 accuracy competition: Results, findings, and conclusions. International Journal of Forecasting, 38(4), 1346–1364.
  2. Makridakis, S., Spiliotis, E. & Assimakopoulos, V. (2020). The M4 Competition: 100,000 time series and 61 forecasting methods. International Journal of Forecasting, 36(1), 54–74.
  3. Hyndman, R. J. & Athanasopoulos, G. Forecasting: Principles and Practice (3rd ed.). OTexts.
  4. Salinas, D., Flunkert, V., Gasthaus, J., & Januschowski, T. (2020). DeepAR: Probabilistic forecasting with autoregressive recurrent networks. International Journal of Forecasting, 36(3), 1181–1191.

Reading settings

Saved on this device. Changes apply as you choose them.

Theme
Text size
Typeface for reading
Line spacing
Line length
Start each topic at

Deeper levels stay one click away whichever you choose.

Preview

Safety stock covers the surprises while you wait for a delivery. It grows with the square root of lead time, not with lead time itself.

Lines

↑ ↓ move ↵ open Topics marked “Soon” open their line