# Agent context: Empty Shelves and Excess Stock

Source: https://aiplaybooks.app/industries/retail/inventory-planning/stockouts-and-overstock
AI suitability: conditional

## Objective

Produce stockout-corrected demand forecasts and order quantities per product and store that raise measured on-shelf availability without increasing markdowns, waste, or days of supply, and surface inventory records that no longer match the shelf.

## Constraints

- Never train or evaluate on raw sales. Flag stockout periods and replace their sales with a demand estimate first, and only ever replace a lower recorded figure, since a stockout can hide demand but never add to it.
- Do not trust the perpetual inventory record as ground truth. A product with stock on record and no sales for an implausible run of days is a candidate phantom stockout, not a non-selling product.
- Never correct an inventory record, cancel a supplier order, or write off stock automatically. A store worker or planner confirms first.
- Benchmark every forecast against a seasonal naive forecast and exponential smoothing on the same backtest periods, per category.
- Use a scaled error metric and report bias separately. Do not use MAPE at product and store level.
- Set order quantities from a demand quantile tied to the planner's service level target, not from a point forecast.
- Respect case pack, minimum presentation stock, and shelf capacity when converting a forecast into an order.
- Use loyalty or basket data only in aggregated form.

## Inputs

- Daily or weekly units sold and price paid per product and store.
- Daily on-hand quantity, on-order quantity, and recorded out-of-stock events per product and store.
- Receipts, transfers, write-offs, and count adjustments.
- Promotion and price calendar, with discount depth and display placement.
- Product hierarchy, case pack, shelf capacity, shelf life, store cluster, lead time, and delivery schedule.
- Service level target per category, set by the planner.

## Outputs

- A stockout-corrected demand history per product and store, with the corrected periods marked.
- Demand quantiles per product and store over the lead time and review period.
- A proposed order quantity per product and store, with the on-hand, reorder point, and quantile that produced it.
- A daily phantom inventory list per store, ranked by how implausible the sales gap is and truncated to the time store staff have to check it.
- A per-category backtest comparing each forecast with the benchmarks, visible to planners.

## Success criteria

- On-shelf availability measured by shelf audit rises in the target categories against matched control stores.
- Markdown, waste, and days of supply do not rise to pay for the availability gain.
- Forecast bias on corrected demand is near zero per category, and the forecast beats the seasonal naive benchmark wherever it is used.
- A meaningful share of phantom inventory flags are confirmed empty or found in the backroom when checked.
- Planner override rate falls, and logged overrides can be compared against the system order they replaced.

## Known pitfalls

- Training any forecast on raw sales history, so stockout days teach it that demand is low and it orders even less next time.
- Reporting availability from the system's own inventory records, which counts phantom stock as on the shelf and hides the problem the project was meant to fix.
- Judging a forecast on MAPE at product and store level, where most periods are zero or near zero and the metric becomes undefined or meaningless.
- Replacing a planner-trusted process with a black box score and no comparison against a simple seasonal benchmark, so nobody can show the new model is better.
- Setting order quantities from the point forecast alone, which guarantees stockouts on roughly half of periods for any product whose demand is symmetric around it.
- Buying an AI forecasting tool to fix empty shelves whose real cause is backroom stock not reaching the shelf.

## When not to use AI here

- Inventory record accuracy is unknown or known to be poor, so record correction will move availability more than any forecast change.
- Most empty shelves have stock in the backroom, which is a store execution problem that a forecast cannot solve.
- The product range is small and stable enough that reorder points and a seasonal average already hit the service level target.
- Promotions and price changes are not recorded, so the drivers a model would need to learn from do not exist in the data.
- The product is new or one-off with no comparable history, where planner judgement and analogues from similar products beat any trained model.

## Candidate approaches

- Reorder points and service level safety stock (primary): Per product and store reorder points and order-up-to levels that turn a demand forecast, the delivery lead time, and a planner's service level target into an order quantity.
- Stockout-corrected baseline forecast (primary): Exponential smoothing per product and store, or per group for slow sellers, fitted to a sales history in which stockout periods have been replaced with an estimate of the demand they hid.
- Phantom inventory screening (discovery): Flags products whose sales have stopped for longer than their demand history makes plausible while the inventory record still shows stock, and sends a store worker to check the shelf.
- Pooled demand model with quantile forecasts (supporting): One gradient boosted model trained across many products and stores at once, using promotions, price, and calendar features, that outputs demand quantiles for the products where the baseline forecast is weakest.

## Human oversight

Planners own service level targets, promotion and launch forecasts, and the decision to override an order, and every override is logged so its effect can be measured. Store staff confirm a phantom inventory flag on the shelf before the record is corrected. No model changes a service level target, cancels a supplier order, or writes off stock on its own.

## Sources

- [Demand Forecasting with Censored Likelihood](https://juanitorduz.github.io/demand/), Juan Camilo Orduz, 2024, practitioner
- [Forecasting: Principles and Practice, 3rd edition](https://otexts.com/fpp3/), Rob J Hyndman and George Athanasopoulos, OTexts, practitioner
- [Inventory Record Inaccuracy: An Empirical Analysis](https://doi.org/10.1287/mnsc.1070.0789), Management Science, 2008, research
- [Desperately seeking shelf availability: an examination of the extent, the causes, and the efforts to address retail out-of-stocks](https://doi.org/10.1108/09590550310507731), International Journal of Retail & Distribution Management, 2003, research
- [M5 accuracy competition: Results, findings, and conclusions](https://doi.org/10.1016/j.ijforecast.2021.11.013), International Journal of Forecasting, 2022, research
- [A decision support system for detecting products missing from the shelf based on heuristic rules](https://doi.org/10.1016/j.dss.2008.11.004), Decision Support Systems, 2009, research
