Accounting for Censored Demand in Sales Forecasting

Sawyer Birnbaum, Machine Learning Product Manager

Afresh Engineering
Afresh Engineering

--

At Afresh, our mission is to reduce food waste and make fresh food more accessible by transforming the fresh food supply chain with technology. Every year, one-third of food produced goes to waste, globally. In the United States, 40 percent of all food waste occurs at the retail and consumer level, with the highest occurrence in fresh food departments. We build solutions for better store-level forecasting, ordering, and operations for fresh food, so they can boost profits and bring fresher food to their communities.

At the heart of every food waste minimizing order is an accurate forecast of future demand. To produce such a forecast, we rely heavily on past sales, which under most circumstances offer a window into past demand. The factors contributing to the demand for an item may be complex — a conglomeration of traits such as price, weather, seasonal trends, and the idiosyncrasies of a store’s customer base — but ultimately, past sales demonstrate how these factors come together to impact demand, and they therefore serve as a basis for our demand model.

In some cases, however, sales do not reflect demand. This occurs when inventory of an item runs out or falls to a visually unappealing level that discourages purchases. On a day when a store has only 50 apples in inventory, it cannot sell more than 50 apples, regardless of the demand. The divergence between the sales of an item and the demand for that item is known as “demand censoring” (because the available inventory “censors” the observed demand), and it can seriously undermine recommendation accuracy.

When training a demand forecasting model, demand censoring reduces the quality of the training data and therefore the quality of the model. For example, if a large promotion in the training data resulted in a stockout, the model may fail to fully appreciate the impact of the promotion, which could result in under-forecasting if the promotion happens again. Additionally, demand censoring can magnify the cost of under-predicting. If demand censoring occurs when the model recommends too little, not only will there be an immediate cost to the store due to the under-prediction, but — because we use past sales as a feature in our model — the lower sales will push the model towards lowering its demand forecast, potentially exacerbating the under-prediction problem. In the worst case, a model that does not account for demand censoring can become trapped in a “death spiral” in which lower demand forecasts result in lower inventory which in turn leads to lower sales and therefore even lower demand forecasts.

To avoid the problem of censored demand, we use a two-step process: (1) we identify days with censored demand, and (2) we impute the true demand on those days. If we have inventory data on a frequent basis, we can flag days when inventory dropped to zero as days with likely demand censoring. When frequent inventory counts are not available, we look for patterns in the shipments and sales data that indicate possible censoring. (This often applies to the period before the launch of the Afresh product, as grocery chains’ records normally provide only a snapshot of inventory every few weeks.) For example, if sales briefly drop to near zero for a normally high-volume item, then the item likely went out of stock. Once we identify a set of days with imputed demand, we adjust the sales on those days to reflect our estimate of the true, uncensored demand.

The below figures display the detection and imputation processes, using the demand censoring detection algorithm that does not rely on inventory. The first figure shows the sales pattern for a fictional produce item. Days with possible demand censoring are noted with blue lines. The second figure shows the sales patterns after imputing the demand on these days. After imputing the demand, some of the irregularities in the sales data have been eliminated, resulting in a more predictable (and hopefully more accurate) picture of the demand for this item.

Sales before adjusting for censored demand.
Sales after adjusting for censored demand

Accounting for censored demand is a challenging task and a vital one for providing good recommendations. As the above figures show, our system allows us to identify days with censored demand and recover an estimate of the latent demand. And we are experimenting with techniques to improve our ability to detect demand censoring and to more accurately impute the demand on these days, such as better accounting for the sales of substitute items. We look forward to sharing our results!

We are growing our team rapidly and are looking for passionate, talented engineers to help us solve more problems like this. If you are interested in joining, take a look at our current openings.

--

--

Afresh Engineering
Afresh Engineering

We’re a social impact company leveraging new and emerging technology to prevent food waste, one of the #1 ways to curb climate change. Learn more at afresh.com.