DEMDemandStop 5 of 12
- Forecasting fundamentals
- Demand patterns & classification
- Exponential smoothing & ETS
- Intermittent demand: Croston, SBA, TSB
- ML & global forecasting models
- Forecast accuracy & bias
- Probabilistic forecasting
- Hierarchical forecasting
- Promotions, cannibalization & halo
- New products & phase-outs
- Demand sensing & shaping
- 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.
Read atChange any time
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.
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.
| Week | Sales (target) | Sales 1 week before | Same week last year | Price (₹) | On promotion | Festival week |
|---|---|---|---|---|---|---|
| 40 | 1,150 | 980 | 1,020 | 199 | No | No |
| 41 | 1,890 | 1,150 | 1,060 | 149 | Yes | No |
| 42 | 1,420 | 1,890 | 1,300 | 199 | No | Yes |
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 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.
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
- Makridakis, S., Spiliotis, E. & Assimakopoulos, V. (2022). M5 accuracy competition: Results, findings, and conclusions. International Journal of Forecasting, 38(4), 1346–1364.
- 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.
- Hyndman, R. J. & Athanasopoulos, G. Forecasting: Principles and Practice (3rd ed.). OTexts.
- Salinas, D., Flunkert, V., Gasthaus, J., & Januschowski, T. (2020). DeepAR: Probabilistic forecasting with autoregressive recurrent networks. International Journal of Forecasting, 36(3), 1181–1191.