When Stockouts Teach AI the Wrong Demand

Z

ZharfAI Team

September 14, 202612 min read
When Stockouts Teach AI the Wrong Demand

A store opens at 8 a.m. with twelve units of a product. All twelve sell by noon. Nothing arrives before the store closes at 4 p.m. The point-of-sale system records twelve sales, and an AI model receives that number as the day's demand. What did it learn about the afternoon? There were no goods to buy, so the sales record contains no direct observation of the purchases that might have happened.

This hypothetical example exposes a feedback problem: today's stocking decision shapes tomorrow's training data. For retail planners, inventory product owners and data teams, the useful decision is not simply which forecasting model to buy. It is whether the historical target measures demand, a supply-constrained observation, or something too uncertain to label.

Define the demand that sales cannot fully reveal

Demand here means the units customers would purchase during a specified interval, at a specified price, promotion, assortment and service condition, if inventory shortage did not prevent them. It is a conditional quantity, not a permanent preference waiting to be extracted from a transaction table. Change the price or available alternatives and the question changes.

For a deliberately simple single-product, lost-sales setting, with no replenishment during the interval, no backorders and no substitution, observed sales satisfy Y = min(D, Q). Here Y is sales, D is demand and Q is sellable inventory. A sellout tells us D ≥ Q; it does not establish that demand equaled the stock carried.

Statistics calls this a censored observation: the supply limit hides the upper part of the outcome. Censoring does not mean someone deliberately deleted transactions. If customers can place backorders, distinguish requested quantities and request times from fulfillment; that is a different observation process from unrecorded lost sales.

Our broader retail demand-sensing and inventory guide covers the chain from forecast to replenishment. This article examines one earlier question: what did the label supplied to that chain actually measure? A sophisticated model cannot repair a target definition that silently changes between store-days.

Separate zero purchases from no opportunity to purchase

A product available all day with no purchases is not the same training example as a product unavailable from opening. A closed store differs from a broken transaction feed. Replacing every missing or constrained interval with zero teaches a relationship the evidence does not support.

ZharfAI's proposed starting point is an explicit observation state beside every product-location-channel interval:

Interval stateWhat zero recorded sales meansData treatment
Open, buyable product, healthy transaction captureNo purchase was recorded under these conditionsValid observation within the defined scope
Open, product unavailableUnfulfilled demand is not directly knownMark supply-censored observation
Product not offered or store closedThat purchase opportunity did not existSeparate from demand during trading hours
Inventory state or sales feed uncertainEven record completeness is unclearInvestigate quality; do not assign factual zero or imputation

A positive software balance does not establish buyability. Units may be damaged, reserved, in a back room or unavailable through the relevant online listing. Define availability for the actual channel and fulfillment location, not merely the warehouse ledger.

Keep gross purchases and returns distinct. Net sales of zero might represent a purchase offset by a return rather than no buying activity. This classification work should happen before comparing algorithms: otherwise a lower error can reward the model for reproducing accounting or collection artifacts.

Preserve the time stock ran out

Two days with twelve sales can contain different evidence. On one, the last unit sells at noon; on the other, at 3:55 p.m. The second day covers almost the full trading window. Timing helps interpret purchase intensity, although it does not disclose an exact number of unobserved purchases.

Jain, Rudi and Wang show that stockout timing can provide information beyond a binary sellout event in specified demand-arrival models. Their results depend on those assumptions; the paper is not a universal guarantee that one timestamp identifies retail demand. Stock-out timing research, 2015.

Operationally, reconstruct buyable intervals from sales, receipts, transfers, reservations, releases, counts and adjustments. Preserve event time separately from ingestion time. Keep the product, location, channel and quantity unit stable: cases and individual units cannot be added without conversion.

Sometimes the stockout time is only bounded. If a reliable check found stock at 11 a.m. and another found none at 1 p.m., retain that uncertainty interval instead of manufacturing a noon timestamp. The last sale is not necessarily the stockout: a late transaction or an unrecorded removal can break that inference.

The practices in AI data quality and observability apply directly. Treat unresolved availability as a visible quality condition. Quietly “fixing” a balance is particularly dangerous here because that balance determines which targets the model treats as fully observed.

Twelve sales do not establish twenty-four units of demand

Return to the opening example. The product was available for four of eight trading hours. Multiplying twelve by two gives twenty-four. The arithmetic is correct; the assumption remains untested. Would the afternoon have had the same purchase rate? Lunch traffic, a morning promotion or after-work shopping can make uniform extrapolation inappropriate.

The same observed history is compatible with several outcomes. Perhaps nobody else would have bought the product. Perhaps total demand would have reached eighteen or thirty units. These are hypothetical scenarios, not fitted estimates or a confidence interval. A supply ceiling alone does not provide a finite upper bound on demand.

Dropping every stockout day is not a cost-free correction. If high-demand days sell out sooner, the retained sample disproportionately represents quieter days. The model then learns from a selected population. Conversely, filling every unavailable hour with average sales conceals variation rather than resolving it.

Retain raw sales unchanged. Store estimated demand separately, with the method, reference data, version, applicable scope and uncertainty. A planner should be able to distinguish units purchased from units inferred. When defensible methods imply materially different orders, that disagreement is itself decision-relevant evidence, not a nuisance to average away.

Teach the model which observations are incomplete

There are two useful approaches to investigate. One incorporates censoring directly into estimation. In the simple discrete-count setting above, an uncensored observation contributes a probability such as P(D = y), while a sellout at inventory q contributes P(D ≥ q). Predicting demand above observed sales should not receive the same penalty in the second case as in the first.

That is a mathematical explanation of the simple case, not production-ready code for a multi-product retailer. Distribution assumptions, inventory accuracy and the stocking policy matter. If a buyer used private information absent from the model when choosing inventory, the shortage mechanism also needs consideration. Adding an “out of stock” feature to an ordinary model does not automatically resolve identification or selection.

The other approach first estimates demand in censored intervals and then trains a forward forecast. A recent example of relevant data design is FreshRetailNet-50K, June 2026 version five: its authors provide 50,000 store-product time series with hourly sales and stockout annotations. Such records make the problem investigable. The stockout annotations themselves do not turn unobserved demand into directly measured ground truth.

Both approaches still require evidence. For an always-unavailable item with no credible analogues, a larger model does not create missing information. “Insufficient data” may be the correct result. A language model can explain that condition to a buyer; it should not invent lost-sales quantities from correspondence and write them into a reference table.

Account for substitution without counting a purchase twice

When one product disappears, some customers choose another, some defer and some leave. Sales of an available substitute can therefore reflect the original product's shortage. Adding all estimated lost demand for the first item to all observed sales of the second can count one purchase intention twice at category level.

Conlon and Mortimer studied vending-machine data with product availability observed every four hours and used availability changes to estimate substitution patterns. The study supports taking the available assortment seriously; its effect sizes are not universal estimates for other retail formats. Demand under incomplete product availability, 2013.

Specify whether the output estimates first-choice demand for one item or total category purchases under a given assortment. Those quantities answer different replenishment questions. A single-item model should disclose its inability to represent substitution rather than quietly treating substitute sales as independent demand.

Start with aggregate product and store data. This problem generally does not require bringing personal identities into the forecasting table. More customer detail is not a substitute for knowing what was actually offered and buyable at the time.

Do not give yesterday's forecast today's corrected history

A stock adjustment discovered today may reveal that Monday's balance was wrong. It does not mean Monday's ordering system knew the corrected value. Historical decision reconstruction must preserve the information available at the forecast cutoff; corrected records can support investigation without replacing historical inputs.

Google Cloud's forecasting-parameter documentation distinguishes future-known covariates, such as holidays and planned promotions, from values not known at forecast time, such as realized weather. That separation is a useful implementation principle, not a recommendation to purchase the vendor's service.

Tomorrow's actual stockout time cannot be a feature in today's prediction of tomorrow. Planned inventory is not realized inventory either. If the target is demand without supply restriction, inventory may explain the observation mechanism, but it must not silently redefine the target as sales under the existing stock policy.

The distinction between event time and information available for a decision is developed in our temporal truth and decision snapshots guide. Apply it to both stages of a recovery-and-forecast pipeline, not just the final model's feature table. Otherwise the imputer can leak future information even when the forecasting code appears correctly split.

Never grade a forecast against its own invented truth

Use multiple forecast origins, fitting on preceding data and testing the horizon that matters for the order. Refit any demand-recovery step within each permitted historical window too. This ordering follows rolling-origin time-series evaluation, rather than randomly mixing later observations into earlier training examples.

Keep three separate reports. First, measure errors on genuinely buyable intervals. That result applies to the observable subset, which may underrepresent high-demand days. Second, hide portions of complete observations to test reconstruction. This measures performance under the chosen masking pattern, not recovery of all real stockouts. Third, measure how replenishment recommendations change across plausible assumptions about hidden demand.

An imputed table from another model is not the test answer key. Two models may agree because they share assumptions. Even prediction-interval coverage measured on in-stock days does not establish equivalent coverage during stockouts. Report where outcomes were actually observable and where the assessment depended on modeling assumptions.

For unit errors, compare mean absolute error, directional bias and a simple seasonal baseline. Percentage errors become undefined or unstable around zero sales; a scaled metric is also unusable when its baseline denominator is zero. The forecast-accuracy guidance explains these distinctions. No choice of metric turns an invalid label into a valid one.

What evidence should change the order?

If availability timestamps are unreliable, improve observation before replacing the model. If observations are sound but the recommendation is highly sensitive to imputation assumptions, retain buyer review. If evidence is stable within a defined scope, design a bounded operational test. Winning a historical reconstruction exercise does not by itself authorize automatic purchase orders.

For a proposed experiment, select lower-risk, nonperishable items and predefine extra-inventory limits, duration and a stop owner. A comparable control group or random assignment, where feasible, helps separate the intervention from other changes. Account for customers moving between stores and for product substitution when choosing groups. ZharfAI has not conducted this experiment here and claims no resulting commercial improvement.

Do not call higher sales alone a success. Track stockout duration, unknown availability intervals, the proportion of estimated labels, ending inventory, aged stock, waste and cash tied up. Carrying more stock can reveal purchases that were previously unobservable; it can also merely leave capital sitting on shelves. The buyer needs to see both possibilities.

Revisit assumptions after changes in price, promotions, assortment, opening hours or supply policy. The closing question in a replenishment meeting should be concrete: which part of this recommendation comes from recorded purchases, which part is estimated, and what does a wrong estimate cost? An explicit answer is more useful than a precise-looking forecast trained to ignore empty shelves.

Source notes — reviewed September 14, 2026

This is a practical guide and ZharfAI analysis, not a research-release report or investment advice. The twelve-unit example and all numeric scenarios are hypothetical. Sources were opened and the claims used were checked; study performance results are not transferred to another business.

  1. Jain, Rudi and Wang: stock-out timing, Operations Research, January–February 2015; first published online December 4, 2014. Theoretical conclusions depend on model assumptions.
  2. Conlon and Mortimer: incomplete product availability, AEJ Microeconomics, November 2013; original vending-machine research.
  3. Wang and colleagues: FreshRetailNet-50K, version five June 18, 2026; first version May 22, 2025. Hourly data with stockout annotations.
  4. Hyndman and Athanasopoulos: time-series cross-validation, online third edition of Forecasting: Principles and Practice; accessed on the review date.
  5. The same authors: point forecast accuracy, online third edition. These two chapters are not two independent organizational sources.
  6. Google Cloud: forecast training parameters, page updated September 3, 2026; future-known versus unavailable covariates.
#Demand Forecasting#Retail#Inventory#Data Quality#Machine Learning

Related Posts

Name one process for a discovery call

If this note maps to a real system in your organisation, start with the services page or a shipped case study.