Design daily product-demand forecasts for a retailer with thousands of stores.
Forecast the right horizon, distinguish observed sales from demand, and connect uncertainty to inventory decisions.
01. Define the decision and baseline
Assume each store orders inventory nightly for the next seven days. Forecast item–store demand at daily resolution, with uncertainty useful for replenishment. Start with a seasonal baseline such as the same weekday in recent weeks, then compare a shared model that can borrow information across related products.
Clarify whether the objective is fewer stockouts, less waste, or lower inventory cost. These may conflict. A forecasting service should return a versioned prediction; an inventory policy combines it with lead times, constraints, and asymmetric costs.
02. Build labels that reflect the observation process
Recorded sales are not unrestricted demand when shelves are empty. A day with zero sales could mean no interest or no available product. Keep stock availability, promotion, price, and assortment history alongside the labels. Do not silently label a stockout day as genuine zero demand.
Features must be known at forecast issuance: calendar effects and planned promotions may be available, while tomorrow’s actual weather is not. Use the weather forecast that existed at the time if testing that input historically. Preserve corrections and source availability timestamps.
03. Design the batch pipeline
Ingest sales and inventory events, build time-consistent daily aggregates, generate a forecast for each eligible item–store pair, validate outputs, and publish an immutable forecast snapshot. A manifest identifies model version, issuance time, horizon, and source cutoffs. Consumers switch to a snapshot only when completeness checks pass.
For an illustrative 10,000 stores and 2,000 active items each, there are 20 million series. Seven float32 point forecasts per series occupy about 560 MB before keys, quantiles, versions, or storage overhead. Compute, feature joins, and sparse activity can dominate this raw output size.
04. Evaluate and degrade gracefully
Use rolling forecast origins with the same seven-day horizon used by ordering. Compare error by horizon, store, product age, and sales volume; also simulate the inventory policy with clearly stated assumptions. Random row splits can let future conditions inform past predictions.
Fallbacks can use the last valid forecast or a seasonal rule, with freshness exposed to consumers. Follow-up: for a new product, use category and product attributes, widen uncertainty, and learn as observations arrive. A single global error score should not hide failures on new items or highly perishable goods.
Practice the follow-up
Explain why a perfect sales forecast during repeated stockouts may still underestimate the inventory needed.
Connect this to regression metrics.
Sources & further reading
Forecasting: time series cross-validation. The interview scenario, calculations, and proposed design choices are illustrative.
Continue your preparation
Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.