Katkat

Forecast Food Stocking Needs Under Waste and Stockout Costs

C3 AIData Scientist · Technical Screen

Last updated

Design an end-to-end inventory forecasting and stocking optimization system for perishable food items under asymmetric costs of spoilage versus stockouts. The design covers handling censored sales data, probabilistic demand modeling, cost-optimal stocking policies, and validation strategy.

Scenario

A national enterprise food service provider operates commercial kitchens and retail cafeterias across 1,500 locations, stocking roughly 400 distinct perishable food items daily (e.g., prepped salads, sushi packs, fresh dairy, hot-bar proteins). Perishable items have short shelf lives (typically 24 to 72 hours).

Currently, site managers order inventory using static rules of thumb, leading to dual failure modes: excessive food waste (high disposal cost and carbon footprint) or premature stockouts (lost revenue, lower customer retention). You are tasked with designing an enterprise ML system that predicts item-level demand distributions and outputs daily stocking targets to minimize total operating costs.

Requirements

Functional Requirements

  • Probabilistic Demand Forecasting: Produce daily forecast distributions (not just point estimates) over a 7-day rolling horizon for every (store_id, sku_id) pair.
  • Censored Demand Adjustment: Correct historical sales logs where stockouts clipped observed demand below true underlying demand.
  • Inventory Decision Policy: Translate forecast distributions into concrete reorder/stock quantities using item-specific shelf life, lead time, holding/spoilage costs (C_w), and stockout penalty/margin costs (C_s).
  • Decision Explanations: Provide store managers with interpretability signals (e.g., local weather event, day-of-week seasonality, local holiday) driving recommended stocking levels.

Non-Functional Requirements & Scale

  • Scale: 1,500 locations * 400 SKUs = 600,000 distinct daily time series. Nightly batch inference must complete within a 2-hour window before morning replenishment runs.
  • Latency: Nightly batch ingestion and inference pipeline under 120 minutes. Ad-hoc scenario simulation API under 500 ms.
  • Data Drift: System must continuously detect and adapt to menu updates, local demographic shifts, and macro inflation shifts.

What Your Design Should Cover

  1. Data Pipeline & Censored Demand: How to infer true demand when sales equal zero because inventory ran out mid-day (e.g., Tobit models, survival analysis, or explicit un-censoring heuristics).
  2. Modeling Strategy: Candidate architectures for probabilistic forecasting (e.g., DeepAR, MQ-Transformer, or quantile gradient-boosted trees) and why a point prediction is insufficient.
  3. Stocking Policy & Asymmetric Loss: Formulation of the newsvendor problem under asymmetric cost ratios (C_s / (C_s + C_w)), multi-day shelf lives, and batch replenishment.
  4. Validation & Evaluation: Offline evaluation strategy avoiding temporal data leakage (e.g., rolling-window backtesting), choice of loss functions (pinball loss, CRPS), and business metrics (Service Level / Fill Rate vs. Spoilage Ratio).
  5. Deployment & Human-in-the-Loop Rollout: Shadow testing, manager override mechanisms, and champion/challenger A/B testing across regional kitchen clusters.

Hints

Hint 1

When inventory drops to zero before the end of a sales window, observed sales represent a lower bound on demand rather than the true demand value.

Hint 2

The optimal stocking level in classic inventory theory corresponds to the critical fractile quantile of the predicted cumulative distribution function.

Hint 3

Standard k-fold cross-validation will leak future trends into past evaluations; use expanding-window or rolling-window time-series splits matching the true replenishment cadence.

Follow-up questions

  • How would you model cross-SKU substitution when a preferred item runs out and customers choose an alternative item?
  • If a cold-chain telemetry sensor reports a temperature excursion that shortens an item's remaining shelf life from 48 hours to 12 hours mid-day, how should the real-time inference layer adapt?
  • How do you design a safety fallback if the nightly batch pipeline fails or encounters corrupted upstream vendor catalog data?