Every store owner is a forecaster, whether they think so or not. Each time you place an order with a supplier, you are betting on how many units you will sell before the next delivery. Order too few and you run out, losing sales and customers. Order too many and your cash sits in a warehouse, perhaps until the product goes out of season. The cost of getting it wrong is real and recurring, which is why forecasting is one of the most discussed uses of AI in retail.
It is also one of the most oversold. Vendors promise dramatic accuracy gains, and small stores wonder whether they need a machine learning system at all. This guide gives a sober answer. It explains what a demand forecast is, what simple methods achieve, when a learned model genuinely helps, what data it needs, how to measure accuracy without fooling yourself and how to turn a forecast into buying decisions. It follows from the examples in AI in ecommerce: fifteen practical examples and connects to the stock design in inventory sync across sales channels.
What you are really forecasting
A forecast answers a specific question: how many units of this product will customers want over this period? Notice the word want. What you can measure is what you sold, and those two differ whenever you were out of stock. If a product sold out on the tenth of the month, the sales for the last twenty days are zero, but demand was not. A forecast trained on raw sales learns that the product stopped selling, and recommends buying less next time, which makes the next stockout more likely. The first discipline of forecasting is to correct the history for stockouts and to note promotions, so that the model learns demand and not supply.
| Distortion in history | What it does to a forecast | Remedy |
|---|---|---|
| Stockout periods | Makes demand look lower than it was | Mark those days, estimate demand from neighbours or exclude them |
| Promotions and discounts | Creates spikes that are not baseline demand | Record promotion dates and sizes as separate inputs |
| Price changes | Shifts demand without a calendar cause | Include price as an input where you can |
| New products with no history | Nothing to learn from | Borrow from similar products or use a launch plan |
| One-off bulk orders | A single large buyer distorts the average | Flag and cap outliers |
| Marketplace changes and ads | Traffic moves for reasons outside the product | Record ad spend and channel mix |
The baselines every model must beat
Before spending a cent on AI, compute three simple forecasts for each product, because they are cheap and strong. If a clever model does not beat them, it is not worth using.
| Method | How it works | Strength | Weakness |
|---|---|---|---|
| Naive: same as last period | Next week equals last week | Costs nothing; surprisingly hard to beat for stable items | Ignores trend and season |
| Moving average | Average of the last few weeks | Smooths noise | Lags behind changes |
| Seasonal naive | Same period last year, scaled by recent trend | Captures yearly patterns with no maths | Needs a year of clean history |
| Exponential smoothing | Weighted average that favours recent data, with trend and season options | A classic, robust method | Needs tuning and handles promotions poorly |
| Learned model (machine learning) | Learns patterns from history and many inputs together | Can use promotions, price, channel and many products at once | Needs more data, setup and monitoring |
For a small catalogue of steady sellers, a seasonal moving average is often within a few points of a sophisticated model. The advantage of learning grows with the number of products, the strength of promotions and seasons and the cost of an error.
When AI forecasting earns its keep
- Hundreds or thousands of products. A model that learns across the catalogue can borrow strength between similar items, including new ones.
- Strong, repeating promotions or events. A model with promotion inputs can tell baseline from lift.
- Costly errors. Long lead times, expensive inventory or perishable goods raise the value of accuracy.
- Several channels with different behaviour. A learned model can use channel inputs where a single average cannot.
- Enough history. Two or more years of clean, consistent data allow seasons to be learned.
If most of these are false for you, start with the simple methods and improve your data. Our AI demand forecasting service includes a baseline comparison for exactly this reason: the first deliverable is a comparison against simple methods on your own history, so that you see whether learning earns its cost before you pay for a full build.
Data checklist before any model
- Daily or weekly sales by product and channel for at least two years if you have it.
- Stock levels over time, so that stockout days can be identified.
- Promotion calendar: dates, discount size and channels.
- Price history by product.
- Product attributes: category, season, launch date and variants.
- Supplier lead times and minimum order quantities.
- Returns and cancellations, so that net demand is clear.
Measuring accuracy without fooling yourself
A single accuracy percentage can mislead. The commonest measure, mean absolute percentage error, explodes for slow sellers with small numbers: forecasting two units and selling three is a fifty percent error, though it hardly matters. A weighted error, which divides total absolute error by total sales, treats large sellers as more important and is easier to interpret. Whichever you use, compare against a naive forecast, because the question is whether you are better than doing nothing clever.
| Measure | Formula in words | Notes |
|---|---|---|
| Absolute error | The gap between forecast and actual, ignoring sign | Easy to explain; depends on scale |
| Weighted absolute percentage error | Total absolute error divided by total actual sales | Stable across products; prefer for catalogues |
| Bias | Total forecast minus total actual | Shows whether you over or under forecast on average |
| Skill against baseline | How much your error is below the naive forecast’s error | The honest verdict on a model |
| Service level | Share of demand met without stockouts | The business outcome you care about |
Test on a hold-out period the model has not seen: train on data up to a date, forecast the following weeks and compare with what happened. Repeat for several dates, including peak seasons. A model that wins on easy months and loses on peaks is not what you need.
From forecast to buying decision
A forecast is not a decision. To buy well, combine it with lead times, uncertainty and costs. The classic bridge is the reorder point: the stock level at which you place an order. It equals the expected demand during the lead time plus a safety margin for variation.
| Input | Example value |
|---|---|
| Average daily demand | 12 units |
| Supplier lead time | 14 days |
| Daily variation (standard deviation) | 4 units |
| Service level wanted | 95 percent (a factor of about 1.65) |
| Demand during lead time | 12 x 14 = 168 units |
| Safety stock | 1.65 x 4 x square root of 14, about 25 units |
| Reorder point | 168 + 25 = 193 units |
Illustrative numbers. The method assumes demand variation is roughly bell-shaped and independent from day to day; use it as a starting point.
The benefit of a better forecast shows up in these numbers. Improve the demand estimate and the reduced variation lowers the safety stock, which frees cash without raising stockout risk. Better still, a forecast that anticipates a seasonal rise lets you order earlier, before the lead time makes it too late. The alerting side is straightforward once the reorder point exists, and AI purchase order automation drafts the orders for your approval.
A staged way to start
| Stage | What you do | What you learn |
|---|---|---|
| 1. Clean the history | Mark stockouts, promotions and outliers; assemble a weekly sales table | How noisy and incomplete your data is |
| 2. Baselines | Compute naive, moving average and seasonal forecasts for your top products | How hard the products are to forecast |
| 3. Back-test | Compare accuracy on a hold-out period, including a peak | Which method wins where |
| 4. Add a learned model only where it wins | Use it for products or periods where baselines fail | Whether the extra complexity pays |
| 5. Connect to buying | Turn forecasts into reorder points and draft purchase orders | Whether decisions improve |
| 6. Monitor | Track error and bias monthly and retrain when needed | When the world changes |
A worked example
A store with 400 products and $1.2 million of annual sales holds an average of $180,000 of stock. Out-of-stock events cost it an estimated 3 percent of sales. After cleaning the history and moving from a flat average to a forecast that accounts for season and promotions, it cuts forecast error on its top 80 products by about a fifth. The improved accuracy lets it trim safety stock by perhaps 10 percent, releasing about $18,000 of cash, and reduces stockouts so that lost sales fall from 3 to 2 percent, or about $12,000 a year of revenue, perhaps $4,000 of margin. These figures are illustrative and the gains will differ, but they show the two sources of value: less cash tied up and fewer lost sales. They also show why the baseline comparison comes first; a store whose stock is already well managed will see smaller gains.
Sources and further reading
Figures and rules in this guide come from the primary pages below. Platform limits and prices change, so open the page before you build on a number.
- Hyndman and Athanasopoulos: Forecasting: Principles and Practice, free textbook on forecasting methods and accuracy measures
- NIST/SEMATECH e-Handbook of Statistical Methods, background on variation and standard deviation
- Shopify Help Center: inventory, tracking stock in Shopify