๐ข The situation
The operations director is in a panic: the warehouse is stuffed with winter goods, while popular items run out 3 days before restocking. Purchasing is planned "same as last month".
Lena:
"Classic demand forecasting. We need a 4-week-ahead sales forecast for the top 2000 SKUs. The peculiarity of time series: the order of the data is information, and all the usual validation habits work differently here. Start with the naive baselines โ in forecasting they are harder to beat than you think."
๐ฏ Your task
- Understand the series components: trend, seasonality, noise.
- Build features: lags, rolling windows, the calendar.
- Validate honestly (no peeking into the future) and beat the naive baseline.
๐ Theory
Time series components
- Trend โ the long-term direction (the store is growing).
- Seasonality โ repeating cycles: weekly (weekend peaks), yearly (Christmas trees in December).
- Events โ holidays, promos, price changes.
- Noise โ the unexplained part.
Naive baselines โ respect them
- Naive: tomorrow = today.
- Seasonal naive: next Wednesday = last Wednesday.
- Moving average over 4 weeks.
In retail, seasonal naive often delivers 80% of a complex model's quality. A model that can't beat it is wasted time.
Two approaches to forecasting
- Classic series models (ARIMA, ETS, Prophet): good for a single series with clear structure.
- ML on tabular features (boosting): turn the series into a table of "features โ next period's value". For thousands of SKUs with one model โ the industry standard (this is how the M5 competition was won).
Features for the ML approach
- Lags: sales 1, 7, 14, 28 days ago.
- Rolling statistics: mean/median/std over 7/28 days (โ ๏ธ the window ends before the forecast day).
- Calendar: day of week, month, holidays, days to/after a holiday.
- SKU attributes and events: category, price, promo flag.
Validation: forward only
Random K-fold is forbidden: the model would see the future. Use a rolling/expanding window: train up to T โ forecast [T, T+4 weeks] โ shift โ repeat. This mimics real usage.
Metrics: MAE/WAPE (error as a share of volume) โ clear to purchasing; MAPE is dangerous with zero sales.