Quick answer: Machine learning in demand forecasting means using models that learn from sales history together with prices, promotions, holidays, weather and other signals to predict demand by product, location and week. Unlike traditional methods, which mostly extend past sales forward, machine learning can learn how each of those factors moves demand. It works best with clean sales and stock data, a simple baseline to beat, and a forecast that feeds straight into ordering decisions.
Forecast errors are expensive. IHL Group’s 2026 Inventory Distortion Study puts the cost of out-of-stocks and overstocks to retailers at about $1.7 trillion a year worldwide (stock imbalances are one of the seven retail supply chain challenges we cover separately). Better forecasting is one of the main levers: McKinsey wrote in February 2022 that applying AI-driven forecasting to supply chain management can reduce errors by 20 to 50 percent and lost sales and product unavailability by up to 65 percent. Those are McKinsey’s ranges for what is possible, not typical or guaranteed results. Adoption is expected to grow: Gartner predicted in September 2025 that 70 percent of large organizations will adopt AI-based forecasting to predict demand by 2030.
This guide explains how demand forecasting with machine learning works, which models are used, what data you need, a worked example, how to measure accuracy, and how to start.
What Is Machine Learning in Demand Forecasting?
Demand forecasting estimates how much of each product customers will buy, where and when. Traditional methods, such as moving averages, exponential smoothing and ARIMA, project past sales forward. The better ones handle trend and regular seasonality well. Machine learning models learn from many inputs at once, so they can capture effects that don’t repeat on a fixed calendar, such as promotions, price changes, moving holidays and weather.
| Factor | Traditional forecasting | Machine learning forecasting |
|---|---|---|
| Main input | Past sales of the same item | Past sales plus prices, promotions, calendar, weather and more |
| Handles promotions and events | Poorly, often by manual adjustment | Learns their effect from history |
| Learns across items | No, one series at a time | Yes, similar items and stores inform each other |
| New products | No history, so no forecast | Can use the history of similar items |
| Explainability | Easy to follow | Needs explanation tools to show why it changed |
| Effort to run | Low | Higher: data pipelines, monitoring, retraining |
Which Machine Learning Models Are Used for Demand Forecasting?
- Gradient boosted trees (such as LightGBM and XGBoost): the workhorse for forecasting many products at once. They handle many inputs, train quickly and are relatively easy to explain.
- Neural networks (such as recurrent and transformer-based models): useful for long histories and complex patterns, but they need more data and more care to run.
- Pretrained time-series models (such as Amazon’s Chronos and Google’s TimesFM): trained on very large collections of time series and able to forecast with little setup. They are worth testing as another baseline.
- Statistical baselines (moving average, exponential smoothing, ARIMA): still essential, because a machine learning model is only worth running if it beats them.
In practice, the data and the setup matter more than the choice of algorithm. A well-fed gradient boosted model usually beats a sophisticated model trained on poor data.
What Data Do You Need?
- Sales history by product, location and day or week, ideally covering at least two full seasonal cycles.
- Stock and stockout records, so the model doesn’t learn that demand was low when the shelf was simply empty.
- Prices and promotions, past and planned.
- Calendar effects: public holidays, paydays, school terms and moving holidays such as Ramadan and Eid.
- External signals where they matter: weather, local events and marketing activity.
- Product and location attributes: category, size, store type and channel, which help with new products and new stores.
Most of this already sits in your ERP, point-of-sale and warehouse systems. If those systems don’t share data, connect them first; our guide to ERP and WMS integration explains how.
AI for supply chains
Facing these problems in your own supply chain?
We build AI that works inside your ERP and WMS: demand forecasting, inventory optimization and real-time decision support.
A Worked Example: Forecasting Dates Before Ramadan
This is a simplified illustration with made-up numbers, to show the method.
A food distributor in Dubai sells packaged dates to supermarkets. Sales jump in the weeks before and during Ramadan, which starts about 11 days earlier each year. It also runs a price promotion in some weeks.
| Week | What happened | Actual sales (cases) | 4-week moving average forecast | Machine learning forecast |
|---|---|---|---|---|
| 1 | Normal week | 1,000 | 1,000 | 1,020 |
| 2 | Two weeks before Ramadan | 1,500 | 1,000 | 1,450 |
| 3 | Week before Ramadan, with a promotion | 2,400 | 1,125 | 2,250 |
| 4 | First week of Ramadan | 2,200 | 1,475 | 2,300 |
The moving average only reacts after sales have already risen, so it falls short by 500 to 1,275 cases a week, exactly when demand matters most. The machine learning model has a “weeks to Ramadan” input and a “promotion” input, and has learned their effect from earlier years, so it moves with demand. Across the four weeks, the moving average’s total error is 2,500 cases on 7,100 sold, a weighted error (WAPE) of about 35 percent; the machine learning forecast’s total error is 320 cases, about 4.5 percent. Real gaps are usually smaller; the point is where the error falls, not the size of the improvement.
The forecast then drives stock decisions: how many cases to order from the supplier, and how much safety stock to hold. Safety stock is set from the size of the forecast errors, so a smaller error means less stock is needed for the same service level.
How to Measure Forecast Accuracy
- Weighted absolute percentage error (WAPE): total absolute error divided by total actual sales. It is more stable than the per-item percentage error (MAPE) when some items sell very little.
- Bias: whether forecasts run consistently high or low. A forecast can have a low WAPE and still lean one way every week, which builds up excess stock or stockouts.
- Against a baseline: always compare with a simple method, such as last year’s sales or a moving average. The improvement over the baseline is the real result.
- At the level of decisions: measure accuracy by product, location and week if that is how you order, not only in total.
How AI Is Transforming Demand Forecasting
For e-commerce, AI demand forecasting also uses site traffic, search and cart data, which move before orders do. Across industries, the main changes are:
- Demand sensing: short-term forecasts that update daily from the latest orders, point-of-sale data and signals such as weather.
- Ranges instead of single numbers: probabilistic forecasts give a likely range, which feeds safety stock directly.
- Automatic model selection: testing several models per product group and choosing the one that performs best.
- Explanations for planners: showing which factors moved a forecast, and generative AI assistants that summarize changes in plain language. See our guide to generative AI supply chain use cases.
- Pretrained forecasting models: models such as Chronos and TimesFM lower the effort to get a first forecast running.
Common Challenges
- Hidden stockouts: if a product was out of stock, sales understate demand. Flag those periods or the model will under-forecast.
- New products: with no history, use attributes and similar items, then switch to the product’s own data as it builds.
- Promotions that steal sales: a promotion on one item can lower sales of another. Model related items together.
- Trust: planners override forecasts they don’t understand. Show the drivers and track accuracy openly.
- Drift: customer behavior changes. Monitor accuracy and retrain on a schedule.
How to Start
- Pick a scope: one category or channel where forecast errors are costly, such as your top 20 percent of products by revenue.
- Set a baseline: measure today’s forecast accuracy and bias, and the stockouts and excess stock that follow.
- Prepare the data: sales, stockouts, prices, promotions and calendar, at the level you order.
- Test against the baseline on past periods the model hasn’t seen, before using it live.
- Connect the forecast to ordering, so it changes purchase orders and safety stock, not just a report.
For the wider picture of AI in planning, inventory and logistics, see our guide to AI in supply chain optimization and planning.
How Shispare Can Help
- SKU Predict: our AI demand forecasting product for e-commerce and supply chains. Machine learning weighs seasonality, pricing, promotions, weather and events to predict demand, helping you avoid stockouts and waste. See our products.
- Predictive AI: custom forecasting models built on your own data. See our predictive AI services.
- AI supply chain consulting: connecting forecasts to inventory, purchasing and warehouse decisions. See our AI supply chain consulting.
We work from Dubai (DIFC), St. George, Utah, and Karachi. To talk about forecasting, contact us, or start with our free AI readiness assessment.
Results from our own work
From about 2,900 open requests to about 50
For a US logistics company, our AI system now takes 78 percent of the steps on a return. Let's look at where AI can take work off your planning, inventory or logistics teams.
Frequently Asked Questions
What is machine learning in demand forecasting?
It is the use of models that learn from sales history together with prices, promotions, calendar events, weather and other signals to predict demand by product, location and period. The models learn how each factor moves demand instead of only extending past sales forward.
Is machine learning better than traditional demand forecasting?
Usually, when demand is driven by promotions, prices, events or weather and there is enough clean data. For stable products with regular patterns, a simple statistical method can be just as accurate. Always compare against a simple baseline.
What data do you need for machine learning demand forecasting?
Sales history by product, location and period, stockout records, prices and promotions, calendar events such as holidays, and, where relevant, weather and local events. Product and store attributes help with new items and new locations.
How accurate is machine learning demand forecasting?
It depends on the product, the data and the forecast level. McKinsey reported in 2022 that AI-driven forecasting can reduce errors by 20 to 50 percent in supply chain management. The meaningful measure is the improvement over your current method, tracked with WAPE and bias.
How is AI transforming demand forecasting?
Through demand sensing that updates forecasts daily, forecasts given as ranges instead of single numbers, automatic model selection, explanations that show planners why a forecast changed, and pretrained models that make a first forecast faster to set up.


