Skip to content

RashaGupta/walmart-demand-forecasting

Repository files navigation

🏪 Walmart Demand Forecasting & Inventory Optimization

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.


📌 Business Problem

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

🧠 Solution Overview

This project implements a segmented forecasting and inventory strategy:

1️⃣ Demand Forecasting (Weekly)

  • Classical time-series models (ETS)
  • Global machine learning model (Random Forest)
  • Naive & seasonal naive baselines for benchmarking

2️⃣ ABC–XYZ Classification (Store–Department Level)

  • 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.


📦 Inventory Optimization

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.


🧪 Modeling Approach

🔹 Baselines

  • Naive
  • Seasonal Naive

🔹 Statistical Models

  • Exponential Smoothing (ETS)
  • Used primarily for AX / BX segments

🔹 Machine Learning

  • Global Random Forest Regressor
  • Trained across all Store–Department combinations
  • Feature engineering includes:
    • Lagged demand
    • Rolling statistics
    • Calendar effects

🔹 Evaluation Metric

  • WMAPE (Weighted Mean Absolute Percentage Error)
    Retail-friendly metric that penalizes errors proportionally to volume.

📊 Key Results

Overall Performance (Global ML Model)

  • WMAPE ≈ 0.089

Segment-wise Performance (example)

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


🧰 MLOps & Experiment Tracking

  • 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.


🖥️ Streamlit Application

Features

  • 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)

Pages

  • Home: Business context & segmentation summary
  • Demand Forecast: Time-series forecasts
  • Inventory Recommendation: Policy metrics

About

End-to-end demand forecasting and inventory optimization using MLflow and Streamlit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors