Skip to main content
A retailer or a consumer goods company needs to know how many units of each item each store will sell in the coming days or weeks. The forecasts drive orders to suppliers, transfers between stores and warehouses, and the stock set aside for promotions. This page shows how to set this up with tabSutra.
For the business side of this problem, and how it compares with classic machine learning, read the case study on our website: Demand forecasting for every SKU in every store.

The table

Use one row per item, store and day. Keep every day, including days with no sales, which are zeros, not missing rows.
sales.csv

Forecast the next 28 days

Send all the items of a store, or all the stores of a region, in one request. The series are read together, so an item launched three weeks ago gets a forecast informed by similar items, rather than by its three weeks alone.

From a forecast to an order

A single number is not enough to set a stock level. The right level depends on the cost of running out against the cost of holding stock. With a full predicted distribution, you pick the quantile that matches that trade-off.
  • For a fast-moving staple with a high cost of a lost sale, order up to a high quantile of the demand over the lead time, such as the 95% quantile.
  • For a perishable item, where unsold stock is thrown away, order closer to the median.
The demand over a lead time of several days is a total of several steps. Its mean is the sum of the daily means. Its quantiles are not the sums of the daily quantiles. If you set orders on a weekly total, forecast the weekly total as a series of its own, at a weekly step.

Slow-moving items

Many items sell on only a few days. Their median forecast is often zero, which does not mean that no stock is needed. Read the upper quantiles: the 90% quantile of a spare part tells you how many units cover nine weeks in ten.

Check before you use it

Compare mase with 1, the score of a seasonal naive forecast that repeats last week. Look at inside_80pct_interval too. If it is far below 0.8, the stock levels set from the quantiles will run out more often than planned.

Things that often go wrong

  • Missing days. A day with no sales must be a row with zero units. If such days are left out, the model sees a series with gaps, not a series of zeros.
  • Stock-outs read as low demand. A day without stock shows zero sales. Mark it, or the forecast learns that demand was zero.
  • Promotions known late. A promotion added to future_rows only after the forecast was made cannot help that forecast. When you evaluate, use the promotion plan as it was known at the time.