Blog / ML & Forecasting

ML & Forecasting

Demand Forecasting Methods: From Statistics to Machine Learning

How the main demand forecasting methods work, when each one fits, and how to choose by history, series count, horizon and the cost of an error.

Zentavor Engineering12 min read

Find a starting method

How many series do you forecast?

Do promotions, prices or weather move sales?

Do many items go days without a sale?

Do you plan at several levels (store, region, network)?

Start with

Gradient boosting on features

One model learns from every series at once and takes promotions, prices and weather as features.

    Benchmark it against the seasonal naive forecast.

    Read about this method

    Demand forecasting estimates how much of each item customers will buy over a given period, so the business can plan orders, stock, staff and promotions. Which demand forecasting method fits depends on four things: how much history you have, how many series you forecast (item × store quickly runs into tens of thousands), the horizon, and which mistake costs more, forecasting too low or too high. For a few hundred series with steady seasonality, exponential smoothing or ARIMA is usually enough. For tens of thousands of series whose sales move with promotions and prices, gradient boosting on features works better. Neural networks pay off at large volumes and long horizons. Whatever you choose, compare it with a naive forecast first.

    The charts below run on synthetic series and compute every number in your browser, so you can change a parameter and watch what a method does. Figures from our own projects are marked and link to the page that publishes them.

    Types of demand forecasting: qualitative and quantitative methods

    Demand forecasting techniques fall into two groups. Qualitative methods rely on judgement: expert opinion, the Delphi method, sales-team estimates and market research. They lead when there is no comparable history, for example a new category or market, and they stay useful for adjusting a forecast to news the data hasn’t seen yet. Quantitative methods learn from data: time series forecasting methods use a series’ own past, and causal or machine learning methods add the drivers of demand such as price, promotions and weather.

    This guide covers the quantitative methods, from simple baselines to statistical forecasting and machine learning, because they are what runs every day across thousands of items and stores.

    A baseline to beat

    Before choosing a model, you need a point of reference. The naive forecast says tomorrow sells what today sold. For seasonal demand, the seasonal naive forecast says this Saturday sells what last Saturday sold. A moving average of the last few weeks works too.

    These forecasts take a minute to build, and on short, stable series they’re hard to beat. If a complex model can’t beat the seasonal naive forecast in a backtest, stop developing it.

    A backtest should run the way the model will run in production. Train on data up to a date, forecast the following weeks, move the date forward and repeat. This is a rolling-origin backtest, also called time series cross-validation. Splitting a series at random doesn’t work: the model sees the future and reports an accuracy it won’t have later.

    How to split a series for a backtest

    4 folds, each trained only on the past

    A rolling-origin backtest over 126 days: each fold trains on the days before its origin and tests on the days after it; a random split instead scatters test days among training days.
    • Training days
    • Test days
    • Not used yet

    Each fold forecasts days the model has never seen. In the random split, test days land between training days, and the model has already seen what came after them.

    Statistical forecasting methods

    Exponential smoothing: ETS and Holt-Winters

    The forecast is a weighted average of past sales in which recent weeks count more than older ones. Holt-Winters forecasting adds a trend and a seasonal pattern. ETS is the name for the whole family; forecasting libraries pick the best member for each series automatically.

    y^t+1=αyt+(1−α)y^t

    α is the smoothing weight, between 0 and 1. A sale k days old gets weight α(1 − α)k, so at α = 0.3 half of the total weight sits on the last two days.

    Smoothing fits when you have few series, steady seasonality and at least two full seasonal cycles of history: a few weeks for a weekly pattern, two years for a yearly one. It runs fast, and a planner can see where the number came from. It doesn’t see external factors, so a promotion or a price change passes it by.

    One series, five methods, the last four weeks held out

    Seasonal naive: WAPE 8.7%

    Synthetic daily sales over 18 weeks with a weekly pattern and a slow upward trend; the last 4 weeks are held out and forecast by the chosen method.
    MAPE
    8.9%
    WAPE
    8.7%
    Bias
    −4.2%
    WAPE against seasonal naive
    the baseline itself
    y^T+h=yT+h−m⌈h/m⌉

    Each day repeats the same weekday of the last week, m = 7.

    • Actual sales
    • Forecast
    • Seasonal naive, drawn under the other methods
    • Held-out weeks

    Holt-Winters beats the baseline here because it follows both the weekly pattern and the slow trend. With γ at 0 its weekly pattern stays at the first week’s shape, and the error grows.

    ARIMA and SARIMA

    ARIMA describes a series through its own past values and its past forecast errors; SARIMA adds seasonality. Feed it external variables such as price and promotion dates, and it becomes ARIMAX.

    ARIMA suits the same problems as ETS and helps most when a series has strong autocorrelation. Each series is tuned on its own, which gets expensive and fragile across tens of thousands of them. Sharp promotion spikes are hard for ARIMA as well.

    Prophet

    Prophet splits a series into trend, seasonality and holiday effects, which makes it convenient when holidays drive sales.

    Croston’s method for intermittent demand

    Many items don’t sell every day: spare parts, rare sizes. On these series plain smoothing jumps after every sale and sinks between sales, so its forecast depends on the day you look. Croston’s method forecasts two things separately, the size of a sale and the interval between sales, and divides one by the other. Its TSB variant updates the chance of a sale every period, so the forecast fades when an item stops selling.

    y^Croston=z~tp~ty^TSB=π~t·z~t

    z̃ is the smoothed size of a sale, p̃ the smoothed interval between sales, π̃ the smoothed chance of a sale in a period. Croston updates z̃ and p̃ only on days with a sale; TSB updates π̃ every day.

    Ten weeks of a slow-moving item

    Next-day forecast: Croston 1.40, TSB 2.50, smoothing 2.96

    Daily sales of a slow-moving item over 70 days, mostly zero, with the one-step-ahead forecasts of simple exponential smoothing, Croston’s method and TSB.
    Croston, z̃ ÷ p̃
    5.48 ÷ 3.93 = 1.40
    TSB, π̃ × z̃
    0.46 × 5.48 = 2.50
    Simple smoothing
    2.96
    Average daily sales, last 14 days
    1.79
    • Units sold
    • Croston
    • TSB
    • Simple smoothing

    With the stop after day 45 switched on, TSB drifts towards zero. Croston keeps forecasting sales that will never come: it only updates on days with a sale.

    Use it for the long tail of the range, items that sell a few times a month. To set their stock, order at a quantile of a probabilistic forecast, as shown below.

    Machine learning demand forecasting on features

    Besides a series’ own history, a feature-based model gets outside data: the calendar and holidays, prices, promotions, weather, stock levels, sales of similar items. Each day of an item’s sales in a store becomes a row in a table, and the model learns from all the rows at once.

    Linear regression

    It’s a good place to start: you see straight away how many units a promotion or a weekend adds. Its effects simply add up unless you add interaction terms by hand. In practice the same discount lifts sales more on a hot day than on a rainy one, and a plain linear model won’t notice.

    Add the drivers of demand one by one

    WAPE 14.1% on the held-out weeks

    Synthetic daily sales of one item over the last 12 weeks with the forecast of a linear model built from the switched-on features; the last 4 weeks are held out.
    WAPE, held-out weeks
    14.1%
    WAPE on promotion days
    25.6%
    Promotion adds
    off
    Each °C adds
    off
    Each +1 in price changes sales by
    off
    Promotion on a hot day adds
    off
    • Actual sales
    • Model
    • Promotion day
    • Held-out weeks

    Fitted by least squares on 24 weeks and scored on the last 4. Switched on in the order of the buttons, the error goes 14.1%, 11.7%, 12.3%, 6.1% and 5.4%. The promotion leaves the overall error almost where it was, since only three held-out days have one, yet it halves the error on those days, from 24.0% to 12.5%. The promotion × heat term then recovers what a hot-day promotion adds on top.

    Gradient boosting: LightGBM, XGBoost, CatBoost

    Boosting builds an ensemble of decision trees and finds interactions like discount × weather on its own. In the M5 competition on Walmart sales (42,840 series), most of the top solutions were built on LightGBM.

    One model learns from many series at once, so a slow seller borrows patterns from fast ones and a new item gets a forecast from similar items. Around 24 months of sales history lets the model see the yearly cycle twice. It also needs features: sales over past days and weeks, rolling averages, the calendar, prices, promotions. In our experience the right drivers of demand sharpen the forecast, though a single driver can leave the overall error flat while fixing the days it touches, as the promotion does above.

    Trees don’t extend a trend beyond the values they saw in training. For long horizons, model the trend separately, with a feature or by detrending the series first.

    Neural networks and deep learning

    LSTM, DeepAR, N-BEATS and the Temporal Fusion Transformer learn from thousands of related series at once. Many of them output a probabilistic forecast, a range rather than a single number. In the M4 competition (100,000 series), the winner was a hybrid of exponential smoothing and a recurrent neural network.

    A neural network is worth considering when you have a great many series with long histories, a long horizon, and planners who need a range. It needs more data and compute than boosting, and its output is harder to explain, so compare it with boosting on the same data first.

    Pretrained time series models such as Chronos and TimesFM were trained on large collections of other series and forecast without training on yours. They’re cheap to try as one more baseline.

    Hierarchical forecasting, horizons and ensembles

    Demand is planned at several levels: item in a store, category, region, the whole network. Forecasts built separately at each level disagree: the store forecasts don’t add up to the network forecast. Reconciliation fixes this. You can add forecasts up from the bottom, split the top one down by historical shares, or reconcile optimally with MinT, which combines all levels and trusts the less noisy ones more.

    Three stores and their network, forecast separately

    Stores sum to 920, the network says 980

    A network forecast and three store forecasts made separately, which don’t add up; reconciliation makes the levels agree.
    Stores add up to
    920
    Network forecast
    980
    Gap
    60
    Historical shares
    45%, 33%, 22%
    y~=S(S⊤W−1S)−1S⊤W−1y^

    S maps the stores to every level, W holds how noisy each forecast is. With equal trust (W = I) every node moves by the same amount, here gap ÷ 4 = 15.0.

    Bottom-up keeps the stores and drops the network forecast. Top-down keeps the network and splits it by historical shares. OLS moves every node a little.

    The horizon shapes the forecast too. Each planning cadence needs its own number, refreshed on its own schedule:

    Planning horizons and what each forecast is used for
    HorizonForecastRefreshedUsed for
    DayNext 14 daysEvery morningStore orders for tomorrow
    WeekNext 8 weeksEvery MondayStaff rosters and promotion stock
    MonthNext 6 monthsEvery monthSupplier orders on their lead times
    QuarterNext 4 quartersEvery quarterVolume commitments and warehouse space

    It helps when one demand model feeds all four and each team gets a number built for its own decision.

    An ensemble combines the forecasts of several models by averaging or weighting them. Different methods make different errors that partly cancel, so a combination is usually steadier than any single model. For an energy company we forecast quarterly spend across the whole organisation with an ensemble of neural and statistical models. That’s spend rather than demand, but the method is the same, and aggregate accuracy is 94%, validated by backtest (see our cases).

    Data for demand forecasting: stockouts, promotions and new items

    Sales show demand only on days when the item was in stock. When the shelf runs empty, sales stop at whatever was on it, even though more shoppers came in. A model trained on those days as they are learns a demand that’s too low and orders even less next time. So mark the stockout days and restore demand for them.

    Eight weeks of demand against the stock on the shelf

    Sales understate demand by 8.2%

    Daily units sold over 56 days, capped by the stock on the shelf; on the days demand reached the stock, sales understate demand.
    Stockout days
    27 of 56
    Average sales
    41.3
    Average demand
    45.0
    Restored estimate
    45.6
    • Units sold
    • Sold out
    • Demand (normally unseen)
    • Restored estimate
    • Stock

    A stockout day only tells you demand reached the stock. The restored estimate fits a censored normal per weekday (an EM fit) and replaces each sold-out day with the demand expected above the stock. The lower the stock, the wider the gap between sales and demand. When nearly every day sells out, little is left to restore from, and the estimate drifts too.

    Without a promotion calendar, a model takes a promo peak for seasonality and expects it again next year. Pass promotions, price changes and displays to the model as features.

    A new item has no history, so its forecast comes from its category, price, brand and the sales of similar items in their first weeks.

    Weather and local events sharpen the forecast where demand depends on them, fresh food and drinks for example. In one of our projects the forecast uses more than 120 factors and places replenishment orders itself, with a payback period of 9–12 months.

    Forecast accuracy metrics and the cost of an error

    MAPE, the mean absolute percentage error, is easy for the business to read. It breaks on days with zero sales and inflates the error on small volumes. It also punishes forecasting high harder than forecasting low: an under-forecast can’t cost more than 100%, an over-forecast can cost any amount, so a model tuned on MAPE drifts low.

    WAPE divides the sum of absolute errors by total sales and holds up better on the long tail. Bias shows whether a model runs high or low on balance. Probabilistic forecasts are scored with the quantile (pinball) loss.

    MAPE

    1n∑t|yt−y^t|yt

    WAPE

    ∑t|yt−y^t|∑tyt

    Bias

    ∑t(y^t−yt)∑tyt

    Pinball loss at quantile q

    Lq=max(q(y−y^),(q−1)(y−y^))

    MAPE vs WAPE on a quiet day

    How a quiet day moves MAPE and WAPE

    MAPE 11.3%, WAPE 5.4%

    Actual sales and forecasts for seven days, one of them a quiet day with few units sold.
    MAPE
    11.3%
    WAPE
    5.4%
    Bias
    −0.7%
    The quiet day’s share of MAPE
    63%

    WAPE = 16.0 ÷ 295 = 5.4%

    • Actual sales
    • Forecast

    At zero sales on the quiet day MAPE can’t be computed, while WAPE only moves from 5.4% to 6.9%. Halve every forecast and MAPE reaches 46.9%: an under-forecast can’t push it past 100%. Double them and it reaches 112.5%, with no ceiling above.

    Measure the error separately for each horizon and level. Tomorrow’s error for an item in a store and next quarter’s error for a category mean different things, and one blended number hides both.

    Ordering at the right quantile: the newsvendor model

    Missing low and missing high cost different amounts. Our AI Prediction page uses a yogurt as its example: a lost sale costs $0.62 in margin, and an unsold pot costs $0.29. Ordering at the median forecast costs more here: $68 a day in misses against $61 at the best order. The classic newsvendor model gives the profitable order: it sits at the quantile 0.62 / (0.62 + 0.29) ≈ 0.68, the level that demand stays below on 68% of days. The dearer a lost sale compared with a write-off, the higher the quantile. This needs a probabilistic forecast: a single number doesn’t tell you where the 68th percentile is.

    q*=cucu+co=0.620.62+0.29≈0.68,Q*=F−1(q*)

    cu is the cost of one unit short (the lost margin), co the cost of one unit over (an unsold pot), F the forecast distribution of demand.

    How many pots of yogurt to order for one day

    Order 1,217 pots: misses cost $61 a day, $68 at the median

    The forecast distribution of one day’s yogurt demand with the profitable order at the critical-ratio quantile, and the expected cost of misses by order size, lowest at that order.
    Quantile q*
    0.68
    Order Q*
    1,217
    Expected short
    39 pots, $24
    Expected over
    126 pots, $37
    Cost of misses
    $61 a day
    At the median, 1,129
    $68 a day
    • Days demand stays below the order
    • Profitable order
    • Median forecast
    • Expected cost of misses

    Demand here is the forecast from our AI Prediction page: median 1,129 pots, 80% range 890–1,368. A dearer lost sale moves the order right, a dearer unsold pot moves it left.

    A backtest shows accuracy on past data. The effect on money is checked with an A/B test on real revenue, which is how the +13% on our AI Prediction page was proven.

    Which demand forecasting method when

    Demand forecasting methods: when each fits, when it doesn’t, and the data it needs
    MethodFits whenDoesn’t fit whenData you need
    Naive and seasonal naiveAlways, as the baselineAs the final model when promotions or a trend drive salesAny history
    ETS, Holt-WintersTens to hundreds of series, steady seasonalitySales move with promotions and pricesTwo full seasonal cycles per series
    ARIMA, SARIMA, ARIMAXA few series with strong autocorrelationThousands of series, sharp promotion spikesA regular series without gaps
    Linear regression on featuresA few hundred series where price and promotions matterEffects interact, unless you add the terms by handHistory plus the drivers as columns
    Croston, TSBMany days without a saleItems that sell every dayHistory including the zero days
    Gradient boostingThousands of series, promotions, prices, new itemsA long horizon with a strong trend, unless the trend is modelled separatelyAbout 24 months of history and the drivers as features
    Neural networksTens of thousands of related series, long horizons, a range is neededLittle data, or the forecast must be simple to explainLong histories and compute
    Ensembles and reconciliationPlanning at several levels and horizonsOne series, one horizonForecasts from several models; for reconciliation, forecasts at every level

    Cheatsheet: how to choose a demand forecasting method

    1. Compute the seasonal naive forecast and its error. Every model has to beat it.
    2. Count your series. Up to a few hundred, start with ETS or ARIMA; with thousands, start with gradient boosting.
    3. Check whether promotions, prices and weather move sales. If they do, you need a feature-based model.
    4. Forecast the items with intermittent demand with Croston, TSB or a probabilistic model.
    5. If you plan at several levels, reconcile the forecasts.
    6. Price an under-forecast and an over-forecast, and order at the quantile they imply.
    7. Check the revenue effect with an A/B test. A backtest only shows accuracy.

    Four of these questions are in the method finder at the top of the page.

    FAQ

    What is demand forecasting?
    Demand forecasting estimates how much of each item customers will buy over a given period. Businesses use it to plan orders, stock, staff and promotions. A good forecast is built from sales history and drivers such as price, promotions and the calendar, and checked against a simple baseline such as the seasonal naive forecast.
    What are the main types of demand forecasting?
    There are two groups. Qualitative methods use expert judgement, the Delphi method or market research and suit launches with no comparable history, such as a new category or market. Quantitative methods use data: time series methods such as exponential smoothing and ARIMA, and machine learning methods such as gradient boosting that add price, promotions and weather.
    Which demand forecasting method is the most accurate?
    The one that beats the naive forecast by the widest margin on your own data. In retail with promotions and thousands of items, that is most often gradient boosting on features. On short series with steady seasonality, ETS holds its own against complex models.
    How much sales history do you need for a forecast?
    About 24 months, so the model sees the yearly cycle twice. New items get forecasts from models that learn on similar items.
    Is machine learning better than statistical forecasting methods?
    Machine learning takes outside factors into account and learns from all series at once. On small datasets statistical methods do just as well and are simpler to run.
    How do you forecast demand for a new product?
    From its category, price, brand and the sales of similar items. After a few weeks of sales, the forecast leans more on the item’s own history.
    How do you account for stockouts in sales history?
    Mark the days the item was out of stock and restore demand for them, for example with a censored model. Otherwise the model learns a demand that is too low.
    Which forecast accuracy metric should you use?
    WAPE for the long tail, MAPE for business reports, and bias to catch a model that runs high or low. Report each metric per horizon.

    Further reading: Rob J Hyndman and George Athanasopoulos, Forecasting: Principles and Practice (3rd edition), free online.

    Let's talk

    Which demand forecasting method fits your data?

    Send us your sales history and describe your planning cycle. We’ll scope a forecasting model and its rollout.

    Be the first to know what's next in AI

    We break down complex AI topics into clear, actionable insights, so you can make smarter decisions faster.

    • Fresh AI trends before they go mainstream
    • Practical guides you can apply right away
    • Real enterprise cases, not just theory

    Thanks, you're on the list. We'll be in touch.

    Zentavor FZ-LLC FXMB0126
    Compass Building, Al Shohada Road, AL Hamra Industrial Zone-FZ, Ras Al Khaimah, United Arab Emirates
    +971 56 441 9565