An end-to-end retail demand forecasting and inventory optimization system built on Walmart’s historical sales data, combining time-series models, machine learning, ABC–XYZ segmentation, and MLOps practices, with an interactive Streamlit application for business users.
Retail demand varies significantly across stores and departments:
- High-value items need high service levels
- Slow or erratic items risk overstocking
- A single forecasting or inventory policy leads to:
- Stockouts of critical SKUs
- Excess inventory and working-capital loss
Goal:
Build a behavior-aware system that:
- Forecasts demand accurately
- Classifies SKUs by value and demand variability
- Recommends segment-specific inventory policies
- Serves predictions via a user-friendly app
This project implements a segmented forecasting and inventory strategy:
- Classical time-series models (ETS)
- Global machine learning model (Random Forest)
- Naive & seasonal naive baselines for benchmarking
- ABC → contribution to total sales value
- XYZ → demand variability (Coefficient of Variation)
| Segment | Interpretation |
|---|---|
| AX | High value, stable demand |
| AY | High value, variable demand |
| CZ | Low value, erratic demand |
This segmentation drives both model choice and inventory policy.
For each Store–Department:
- Mean demand
- Demand variability
- Service level (mapped from ABC–XYZ criticality)
- Safety stock
- Reorder point
Inventory logic is segment-aware, not one-size-fits-all.
- Naive
- Seasonal Naive
- Exponential Smoothing (ETS)
- Used primarily for AX / BX segments
- Global Random Forest Regressor
- Trained across all Store–Department combinations
- Feature engineering includes:
- Lagged demand
- Rolling statistics
- Calendar effects
- WMAPE (Weighted Mean Absolute Percentage Error)
Retail-friendly metric that penalizes errors proportionally to volume.
- WMAPE ≈ 0.089
| Segment | WMAPE |
|---|---|
| AX | ~0.04 |
| BX | ~0.08 |
| AY | ~0.11 |
| CZ | ~0.62 |
✔ Stable, high-value segments perform best
✔ Erratic, low-value segments are intentionally conservative
- MLflow used for:
- Experiment tracking
- Model versioning
- Model registry
- Models are registered once and served via alias (
production) - Streamlit loads models dynamically from MLflow
For local development, a file-based MLflow backend (
mlruns/) is used for simplicity and reproducibility.
- Store–Department selection
- Demand forecast visualization
- Automatic model selection (ETS / ML / Naive)
- Inventory recommendations:
- Safety stock
- Reorder point
- Segment transparency (ABC–XYZ shown to user)
- Home: Business context & segmentation summary
- Demand Forecast: Time-series forecasts
- Inventory Recommendation: Policy metrics