tabSutra

Case study · Retail and grocery

Demand forecasting for every SKU in every store

A grocery chain has to decide each week how much of every product to order for every store. This page shows how that forecast is built today with classic machine learning, and how tabSutra builds it from the sales data as it is.

IndustryGrocery, supermarkets, convenience stores and consumer goods
QuestionUnits sold per SKU, per store, per day or week
DataSales, prices, promotions, holidays, stock-outs, product and store details
OutputA forecast with a range for every SKU and store, for every step ahead

The business problem

Take a grocery chain with 300 stores and 25,000 products. Not every store stocks every product, but the chain still has several million SKU and store pairs to plan.

Every week it decides how much of each product to order from suppliers. It decides how much to send to each store. It also decides how much stock to set aside for promotions.

Each of these decisions rests on a demand forecast. If the forecast is too low, shelves run empty and sales are lost. If it is too high, fresh food is thrown away and cash is tied up in stock.

What makes it hard

  • Most series are sparse. A large share of SKU and store pairs sell only a few units a week, with many days of zero sales.
  • The range keeps changing. New products arrive every week and others are dropped. A new product has no sales history.
  • Promotions and price changes move demand sharply. A promotion can double the sales of one product and cut the sales of its neighbours on the shelf.
  • Stock-outs hide real demand. A day with no stock shows zero sales, even when customers wanted the product.
  • Holidays and local events shift demand differently in different stores.

The data a retailer usually has

Most chains already hold everything the forecast needs. It sits in the point-of-sale system, the price and promotion calendar, and the product and store master data.

DataExampleWhen it is known
SalesUnits sold per SKU, store and dayPast only
Prices and promotionsShelf price, discount, promotion typePlanned in advance
CalendarPublic holidays, school holidays, paydaysKnown in advance
Stock-outsDays when the shelf was emptyPast only
Product detailsCategory, brand, pack size, product descriptionFixed for the product
Store detailsFormat, floor area, regionFixed for the store
WeatherForecast temperature and rainKnown a few days ahead

How it is solved today

The usual approach is a classic machine learning pipeline. It is built by a data science team and takes several months to get into production.

  1. The sales are laid out on a full SKU, store and day grid. Missing days are filled with zeros, and stock-out days are marked.
  2. Features are built by hand. Typical ones are sales 7, 14 and 28 days ago, rolling averages, promotion depth, price against the regular price, and days to the next holiday. A mature pipeline has a few hundred of them.
  3. A gradient-boosted tree model, such as LightGBM, is trained for each category or region. Some chains use per-series methods instead, such as exponential smoothing, with Croston's method for slow movers.
  4. The model gives one number per SKU and store. Safety stock comes from a separate rule or a second set of models.
  5. New products get the forecast of a similar product picked by hand, or a category average.
  6. The models are retrained every week or month. When the range, the promotion types or the store formats change, the features are reworked.

Where it falls short

  • The first forecast takes weeks of feature work. A new category or a new market repeats much of it.
  • Lag features of a new product are empty, so the model has nothing to work with.
  • Product and store ids enter the model as codes. A new id has no learned value.
  • Point forecasts do not say how much stock is needed to cover a bad week. Ranges built afterwards are often too narrow.
  • Every category model is one more thing to monitor, retrain and fix.

How tabSutra solves it

The sales table goes in as it is

You send one row per SKU, store and day, with the columns you already have. You add rows for the days to forecast, with the prices and promotions planned for them. You name the column to predict, the columns that identify a series, the date column and the horizon.

Your sales table

SKUStoreDateUnitsPricePromo
Whole milk 1 L214Nov 241821.190
Whole milk 1 L214Nov 251671.190
Olive oil 500 ml214Nov 2506.490
Oat granola 400 g214Nov 2593.991
Whole milk 1 L214Dec 1?1.091

Past rows have units. Future rows carry the planned price and promotion.

tabSutra

  • Reads all the series of a store or region together
  • Represents each product and store by an embedding, not an id
  • Uses only what was known before each forecast date
  • Treats stock-out days as missing demand, not as zero demand

Forecast for next week

SKUMedian80%95%
Whole milk 1 L1,2401,3301,410
Olive oil 500 ml111621
Green tea, 100 bags260295330
Oat granola 400 g New180225270

Store 214, units. A forecast comes for every step ahead, not only the total.

What happens inside

tabSutra is pretrained once on a very large number of tables and time series. It does not need to be trained on your data. It reads your history as context and forecasts from it.

All series are read together

The series of one store or one region are read in a single call. A product with a short or noisy history draws on products that behave like it. A store draws on stores like it.

New products and new stores

Each product and store is represented by an embedding. The embedding is computed from the product's own data, such as its category, pack size, price, description and first weeks of sales. It is not tied to an id. So a product launched last week already has an embedding, and its forecast draws on the products closest to it.

Promotions and prices

Planned prices and promotions are sent with the future rows. The model reads how past promotions moved sales for this product and for similar ones. No promotion features have to be designed.

Stock-outs

When stock-out days are marked, the model reads them as days with unknown demand. A run of empty shelves does not pull the forecast down.

A range for every forecast

Every SKU, store and day gets a full predicted distribution. You can read any quantile from it: the median, the 80% level, the 95% level, or any other.

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 distribution, you pick the quantile that matches that trade-off for each product.

  • Fast-moving staples, where a lost sale is costly: order up to a high quantile of demand over the lead time, such as the 95% level.
  • Fresh and perishable products, where unsold stock is thrown away: order closer to the median.
  • Slow movers: the median is often zero, which does not mean no stock is needed. The 90% level tells you how many units cover nine weeks in ten.
0123 forecast 90% level: 2 units median: 0 past 16 weeks

A slow mover that sells in about one week in three. The median forecast is zero. The 90% level says that two units on the shelf cover nine weeks in ten.

The demand over a lead time of several days is a total. Its mean is the sum of the daily means, but its quantiles are not the sums of the daily quantiles. When orders are set on a weekly total, the weekly total is forecast as a series of its own.

Public data with the same shape

These public datasets have the same shape as the problem. They are listed so that the approach can be checked on open data.

DatasetSourceWhat it tests
M5fev-bench30,490 Walmart product and store series, with prices and events known ahead
Favorita store salesfev-benchGrocery sales by product family and store, with promotions
Rossmannfev-benchDaily sales of 1,115 drugstores, with promotions and store details
Walmartfev-benchWeekly sales by store and department, with markdowns
Rohlik salesfev-benchDaily sales of an online grocer, with 13 known-ahead inputs
Hierarchical SalesGIFT-EvalDaily sales of products in a product hierarchy, from history alone

New launches can be tested by hiding the full history of a sample of M5 products and forecasting them as if they were new.

Side by side

Classic pipeline compared with tabSutra

Classic ML pipelinetabSutra
Time to the first forecastWeeks to monthsHours
FeaturesA few hundred, built and maintained by handNone. The columns go in as they are.
Models to maintainOne per category or regionOne pretrained model for all of them
New products and new storesA similar product picked by hand, or a category averageForecast from day one, from the products and stores closest to it
Slow moversA separate method, or a flat averageThe same model, with upper quantiles to set stock
RangesBuilt afterwards, often too narrowA full distribution for every SKU, store and day
Changes in the range or promotionsFeatures reworked, models retrainedNew rows sent with the next call
Renamed columns or category codesThe pipeline breaksThe forecast does not change

Benefits

What the business gets

Forecasts in hours

The first forecast does not wait for a feature pipeline. A new category or a new market is one more call.

New launches planned from data

A new product or a new store gets a forecast from day one, drawn from the products and stores it resembles.

Stock set by the cost of running out

Every forecast has a range. Each product's stock level can be set at the quantile that suits it.

Slow movers covered

Items that sell a few units a month get a usable forecast, read from the upper quantiles.

One model to run

There are no per-category models to retrain, monitor and fix. A model update reaches every category at once.

Reasons for each forecast

Each forecast shows which inputs moved it, such as a promotion, a price change or the recent trend. Planners can check it before they act.

Questions

How much sales history does tabSutra need?

There is no minimum per product. A product with a long history is forecast mainly from its own sales. A product with a few weeks, or none, draws more on similar products. A year or more of history for most of the range helps the model read seasonal patterns.

Do we need to train tabSutra on our data?

No. The model is pretrained. It reads your history as context in each call. When you have a long history across many stores, it can also be fine-tuned on your data for higher accuracy.

Can it forecast weekly totals, or by distribution centre?

Yes. Send the data at the level you plan at, such as SKU by week or SKU by distribution centre. Forecast a total as a series of its own, so that its range is correct.

How do we check it before we rely on it?

Run it on past weeks as if they were the future, and compare it with your current method on the same weeks. The check reports the error of the forecast and how often the actual sales fell inside each range.

How is our data handled?

Your rows are used only to answer your request. They are not used to train the model. A context you send is kept for a limited time, so that you can predict again without sending it, and you can delete it at any time.

Try tabSutra on your own sales data

API access is open to teams on request. The documentation has a worked example for item and store demand.