Home / Insights / AI and Machine Learning
AI and Machine Learning
Machine Learning Demand Forecasting for Retail and Distribution: Data, Cost Drivers and Rollout
Demand forecasting is one of the most requested machine learning projects in retail and distribution, and one of the easiest to get subtly wrong. This guide covers the data you need, the decisions that drive cost, and how to introduce model forecasts into planning without disrupting it.
TopicsAI and Machine LearningSoftware Costs and BudgetsBusiness Operations and Integration
Key takeaways
- Start from the planning decision the forecast feeds (ordering, allocation, staffing) and the level it is made at: product, store, week.
- Sales history is not demand. Stock-outs, promotions and price changes must be recorded or the model learns the wrong pattern.
- Data preparation and integration usually cost more than the model. Budget for them explicitly.
- Compare against the planners’ existing forecast on a held-out recent period before anyone changes an order.
- Roll out as decision support first: show the model forecast beside the current one and track overrides.
On this page
Retailers, wholesalers and distributors all make the same bet every week: how much of each item to buy, move or stock, before knowing what customers will want. Most already forecast in some form, whether a spreadsheet, a rule in the ERP, or a planner’s experience. Machine learning can improve those forecasts, particularly across large catalogues where no planner can look at every item, but only when the data and the planning process are ready for it.
This article is for operations, supply chain and product leaders scoping a forecasting project. It reflects how we approach machine learning development: a data review and baseline first, then a model compared against the existing planning process. If you have not yet defined how success will be measured, our guide on ML baselines and success metrics is a useful companion.
Define the planning decision before the model
“We want to forecast demand” is not specific enough to build. Pin down four things:
| Question | Examples | Why it matters |
|---|---|---|
| Which decision does the forecast feed? | Purchase orders, store replenishment, warehouse allocation, staff rostering | Determines horizon, granularity and the cost of errors |
| At what level? | SKU by store by day; category by region by week | Finer levels have sparser data and are harder to forecast |
| How far ahead? | Next week for replenishment; several months for imported stock | Longer horizons need different features and tolerate more error |
| How often is it refreshed? | Daily, weekly | Drives pipeline design and running costs |
A common pattern is to forecast at a fairly aggregated level that the model can do well, then split it down using historical proportions. Forecasting every product in every store every day is possible but more expensive, and often unnecessary for the decisions actually made.
The data a forecasting model needs, and the traps in it
Core inputs
- Sales or shipment history at the chosen level, ideally covering at least one or two full seasonal cycles.
- Product attributes: category, brand, price band, lifecycle stage, substitutes.
- Location attributes: store format, region, size, opening dates.
- Calendar: holidays, school terms, paydays, local events relevant to your markets.
- Commercial drivers: promotions, price changes, marketing campaigns.
- Availability: stock levels or stock-out flags.
Sales history is not demand
The most common data problem: when an item was out of stock, recorded sales were zero, but demand was not. A model trained on raw sales learns that the item does not sell on those days and under-forecasts, which causes more stock-outs. You need either stock-out records to exclude or adjust those periods, or a proxy such as low on-hand stock.
Similarly, unrecorded promotions make spikes look random. If promotional history lives in email threads and spreadsheets, collecting it is part of the project. This is a frequent reason a forecasting idea scores high on value but low on feasibility in a prioritisation exercise.
New and slow-moving items
New products have no history, and slow movers have mostly zeros. Both need specific handling: forecasting new items from similar products’ early sales, and using approaches suited to intermittent demand for slow movers. Decide early whether these are in scope for the first release.
Model choices: from statistical methods to global models
| Approach | Strengths | Limitations |
|---|---|---|
| Classical statistical models per series (exponential smoothing, ARIMA-family) | Well understood, explainable, good for stable items with history | Struggle with promotions, new items and many related series |
| Gradient-boosted trees across all series (for example XGBoost or LightGBM with lag and calendar features) | Learn shared patterns across products and stores, handle promotions and attributes well | Need careful feature engineering and time-aware validation |
| Deep learning sequence models | Can capture complex patterns across large catalogues | More data, compute and expertise; harder to explain |
In practice, a single model trained across many products and stores using lag, calendar, price and promotion features is a strong starting point for many retail catalogues, because it can learn from items with rich history to help items with little. Whatever the approach, compare it with the trivial baseline (“same as last year”) and the planners’ current forecast. Our article on recommendation engine algorithms covers a related retail ML problem with similar data challenges.
What drives the cost of a forecasting project
Model training is rarely the biggest cost. The main drivers are:
- Number of data sources and their state. Sales in one ERP is simpler than sales across POS, ecommerce and wholesale systems with different product codes.
- Collecting missing drivers. Reconstructing promotion and stock-out history can take more effort than modelling.
- Granularity and catalogue size. More series means more compute, more validation and more edge cases.
- Integration with planning. Writing forecasts back into the ERP or replenishment system, and building a screen for planners to review and override them.
- Operating the pipeline. Scheduled data refreshes, retraining, monitoring forecast error and data quality, and handling failures. See MLOps and LLMOps.
- Hosting choices. Batch forecasts on a schedule are generally cheaper to run than real-time prediction services.
A useful way to control cost is to phase the work: a first release for one category or region with a clean data pipeline, then expansion once the approach is proven.
Rolling forecasts into planning safely
- Backtest on a recent held-out period. Train on data up to a cut-off, forecast the following months, and compare with actuals and with the planners’ forecasts for the same period.
- Run in shadow mode. Produce model forecasts each cycle alongside the existing process without changing orders. Review differences with planners.
- Introduce as decision support. Show the model forecast in the planning screen next to the current one. Let planners accept or override, and record overrides with a reason.
- Expand gradually. Move categories or regions to model-led planning where it consistently performs well. Keep human ownership for items with special circumstances.
- Monitor continuously. Track error and bias by category, and alert when data feeds are late or unusual. Forecast quality degrades quietly when upstream data changes.
Planner overrides are valuable data. A pattern of overrides for a category often reveals a missing driver, such as a local event or a supplier constraint, that can be added to the model.
Frequently asked questions
How much history do we need?
Enough to cover the seasonal patterns that matter, typically at least one full year and preferably two or more. New products can be forecast from similar items, but the model needs a reasonable history across the catalogue.
Do we need a data warehouse first?
Not necessarily. A forecasting project can build a focused pipeline from the source systems. A warehouse helps when several analytics and AI projects will share the same data.
Will the model replace our planners?
In most rollouts it changes their work rather than replacing it. Planners spend less time on routine items and more on exceptions, promotions and supplier issues where their judgement adds most.
How do we handle unusual periods such as disruptions?
Flag them in the data so the model can account for them, or exclude them from training. Decide case by case, and keep a record of which periods were treated specially.
Sources and methodology
Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.
- scikit-learn: TimeSeriesSplit documentation — Supports the use of time-ordered validation so forecasts are tested on periods after the training data.
Related reading
Continue your research
Could an ML forecast beat your current planning baseline?
We can review your sales, promotion and stock data, build a baseline and backtest a forecasting model against your planners’ forecasts before you change any process.
