Skip to content

johnshun001/demand-forecaster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Powered S&OP Demand Forecaster

A full-stack supply chain decision support system built in Python. Combines machine learning demand forecasting, inventory optimization, and an AI copilot into a live interactive dashboard.


Dashboard Preview

Main S&OP Dashboard

Main Dashboard

AI Supply Chain Copilot

AI Copilot

Model Performance Results

Results Dashboard

Synthetic vs Real Data Comparison

Results Tables


What This Project Does

Most demand forecasting projects stop at the forecast. This one goes further — turning forecasts into actionable inventory decisions and wrapping everything in an AI assistant you can talk to in plain English.

The full pipeline:

  1. Generates or ingests sales data (synthetic + real Rossmann store data)
  2. Cleans and engineers features for machine learning
  3. Trains Prophet and LightGBM models per SKU/store and auto-selects the best
  4. Calculates Safety Stock, Reorder Points, and EOQ for every product
  5. Displays everything in a live Plotly Dash dashboard
  6. Answers natural language supply chain questions via Claude AI copilot

Key Results

Model Synthetic Data MAPE Real Data MAPE
Prophet 12.8% 15.9%
LightGBM 14.9% 6.9%

Key finding: LightGBM improved dramatically on real Rossmann pharmacy data because pharmacy sales are driven by operational features (competition distance, promotions, store type) rather than seasonal calendar patterns. Prophet degraded slightly because necessity goods lack strong seasonal signals.


Project Structure

demand-forecaster/
│
├── modules/                  # Core pipeline modules
│   ├── generate_data.py      # M1 - Synthetic data generation
│   ├── clean_data.py         # M2 - Data cleaning & feature engineering
│   ├── forecast.py           # M3 - Prophet + LightGBM forecasting engine
│   ├── inventory.py          # M4 - Safety stock, ROP, EOQ optimization
│   └── backtest.py           # M5 - 80/20 backtesting evaluation
│
├── dashboards/               # Visual interfaces
│   ├── dashboard.py          # Main S&OP dashboard + AI copilot
│   └── results.py            # Synthetic vs real data comparison
│
├── real_data_pipeline.py     # Rossmann real data integration
├── copilot.py                # Standalone AI copilot (terminal)
├── images/                   # Dashboard screenshots
│
├── data/                     # Generated synthetic data outputs
├── real_data/                # Rossmann store sales data
│
└── README.md

Tech Stack

Tool Purpose
Python Core language
Pandas Data manipulation
Prophet Time series forecasting (Meta)
LightGBM ML-based forecasting (Microsoft)
Scikit-learn Model evaluation metrics
Plotly Dash Interactive dashboard
Anthropic Claude API AI supply chain copilot

Supply Chain Methods

  • Safety Stock: Z-score method at 95% service level (Z=1.65)
  • Reorder Point: (Avg demand × lead time) + safety stock
  • EOQ: Harris-Wilson formula with $50 order cost assumption
  • Backtesting: 80/20 train/test split with MAPE and RMSE evaluation
  • Model Selection: Auto-selects best model per SKU based on test MAPE
  • Sampling: Proportional stratified sampling by store type based on sales contribution

How To Run

1. Install dependencies:

pip3 install pandas numpy plotly dash prophet lightgbm scikit-learn anthropic pyarrow
brew install libomp

2. Add your Anthropic API key: Create a config.py file in the root directory:

ANTHROPIC_API_KEY = "your-key-here"

⚠️ Never commit this file. It is already listed in .gitignore.

3. Generate synthetic data and run pipeline:

python3 modules/generate_data.py
python3 modules/clean_data.py
python3 modules/forecast.py
python3 modules/inventory.py

4. Run main dashboard:

python3 dashboards/dashboard.py

Open http://127.0.0.1:8050

5. Run results comparison:

python3 dashboards/results.py

Open http://127.0.0.1:8051

6. Run real data pipeline (requires Rossmann data from Kaggle):

python3 real_data_pipeline.py

Data Sources

  • Synthetic data: Generated programmatically with realistic seasonality, trends, and promotions across 30 SKUs in Electronics, Apparel, and Food categories
  • Real data: Rossmann Store Sales — 1M+ daily sales records from 1,115 German pharmacy stores. 30 stores selected via proportional stratified sampling by store type based on sales revenue contribution.

Built By

Hunter Johnson — Supply Chain Management, University of Tennessee Knoxville

Built as a portfolio project demonstrating applied ML in supply chain contexts.

About

AI-powered S&OP demand forecasting system with Prophet, LightGBM, inventory optimization, and Claude AI copilot

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages