Demand forecasting with machine learning: SME starter guide
To forecast demand with machine learning, an SME needs a clean sales history, a calendar of public holidays and school breaks, and the dates of its promotions. The model is judged on a period hidden during training, and it has to beat a simple rule such as "same week last year". The people who buy or plan supply validate the gaps before the forecast is used to place orders.
Demand forecasting means estimating what customers will order over the coming days or weeks, product by product or store by store. An SME can start without a team of data scientists, provided it looks at its data first and picks an honest point of comparison. This guide covers what to gather, how to choose a method and how to avoid fooling yourself about the quality of the result.
What data do you need to get started?
Three families of data do most of the work.
Sales history, at the level where the decision is made. If the buyer orders weekly by item, you want weekly sales by item, with the date, the quantity and, if possible, the point of sale. An export from the ERP or the till system is enough at the start.
A calendar. Public holidays, school breaks, working days in the month, company closures. This data is public or easy to rebuild, and it explains a large share of the dips and peaks.
Promotions and prices. Start and end date, type of operation, price charged. Without them, the model takes a commercial operation for a spontaneous rise in demand and then predicts it at the wrong time.
Depending on the business you can add weather, local events or stock levels. On duration, you want to cover the seasonality you care about several times: for a yearly cycle, ideally two years if you have them.
Which methods exist, in short?
Start with a simple rule: the same week last year, or the average of the last four weeks. It becomes the reference for everything else, and it wins more often than people expect on short or irregular series.
Time series methods (exponential smoothing, ARIMA) model each series from its own past: trend, seasonality, level. They work well when series are regular and few outside factors matter.
Gradient boosting models (LightGBM, XGBoost) take a table of variables: sales of previous weeks, day of the month, whether a promotion is running, price, public holidays. They handle promotions and calendar effects well and run on an ordinary machine. They are the usual choice when there are several items and several drivers.
Neural networks for time series exist too. They are mostly worth it when thousands of series are forecast together.
How do you judge a forecasting model?
The only measure that counts is made on a held-out period. You hide the last few months, train on what comes before, ask the model to forecast the hidden months, then compare with what actually sold. Repeat the exercise over several successive periods to see whether the result holds over time.
Shuffling dates at random to build a test set is a classic mistake: the model would see the future during training.
Two simple measures are enough for the error: the average error in units sold (or as a percentage of total volume), and the bias, meaning the tendency to forecast too high or too low. A model that is wrong by a small amount on average but always overestimates fills the warehouse for nothing.
Then comes the deciding question: does it beat the simple rule over the same period? If the gap is small, the simple rule wins, because it is easier to explain and to maintain. Look at product families as well. A model that is good on fast sellers can be poor on slow ones.
Which traps catch a first project?
Data leakage. It happens when the model uses information it would not have had at forecast time: a promotion decided after the fact, a stock level measured on the day, an average computed over the whole series, test period included. The test score looks great and production disappoints. The remedy is to ask, for every column, whether you knew it on the date of the forecast.
Stockouts. A product that is out of stock shows zero sales while customers still wanted it. Mark these periods, or replace them with an estimate before training.
Regime changes. A new product with no history, a range change, a price rise, a store closing. The model cannot guess what it has never seen. These cases are handled separately, often by a rule or by a buyer’s judgment.
A grain that is too fine. Forecasting by day and by item when the decision is made weekly adds noise and brings nothing.
Who should validate the forecast?
The people who know the business. A buyer or a supply planner knows why an item jumped in March, that a given customer switched supplier, that an operation was postponed. A good working format is a review of the largest gaps between forecast and actuals, item by item. Each explained gap leads either to a variable to add or to a decision to handle that case by hand.
The forecast is presented as a suggestion that the person accepts or corrects before ordering. It earns trust when its mistakes can be explained.
And with us?
We are a forward deployed agency: three Télécom Paris engineers specialised in AI, who build custom agents and also take machine learning and data missions. The loop is the same for a forecasting model as for an agent: a first version running on your real data, tested by the people who use it, then adjusted on their feedback. Nothing goes out without the sign-off of someone at your company.
The first call lasts 30 minutes, is free and carries no commitment. To place your project before you call, see the page on AI consulting for SMEs or the one on the AI audit for companies.
Questions
How much history do you need to forecast demand?
Enough to cover several full cycles of whatever you want to capture. For yearly seasonality, two years is better than one, because the model sees each period of the year at least twice. With less, a simple rule is often the best choice.
Do you need deep learning for demand forecasting?
No. For an SME, gradient boosting models or classical statistical methods are enough in most cases. Deep learning becomes a topic when there is a very large number of series to forecast together.
How do you know the model is good?
You ask it to forecast a past period it has never seen, then compare its error with the error of a simple rule over the same period. If it does not do better, there is no reason to put it into production.
Do stockouts distort a forecast?
Yes. A product that is out of stock shows zero sales even though demand existed. These periods have to be flagged in the history, or the model learns that demand was low.