Skip to content

CH-S-K-CHAITANYA/Retail-Sales-Forecasting-Inventory-Optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›’ Retail Sales Forecasting & Inventory Optimization System

Python XGBoost License

An end-to-end retail analytics system that forecasts product demand using machine learning and optimizes inventory using operations research formulas โ€” deployed as an interactive streamlit simulation dashboard.


๐Ÿ“Œ Problem Statement

Retail businesses lose $1.75 trillion globally due to overstocking and stockouts (IHL Group, 2023). Traditional manual stock planning cannot handle thousands of products across multiple stores. This project builds a data-driven system to predict demand and automate inventory decisions.

๐Ÿ’ก Business Value

Problem This System's Solution
Overstock (excess inventory costs money) EOQ calculation minimizes order costs
Stockout (lost sales, lost customers) Reorder point alert ensures timely replenishment
Manual forecasting is slow & inaccurate XGBoost model achieves <10% MAPE
No visibility into inventory health Taipy dashboard shows real-time status

๐Ÿญ Industry Relevance

Companies like D-Mart, Amazon, Walmart, Flipkart, and Reliance Retail use similar systems for:

  • Demand sensing and weekly procurement planning
  • Category-level inventory optimization
  • Festival/seasonal stock preparation
  • Supplier replenishment automation

๐Ÿงฐ Tech Stack

Component Tool
Language Python 3.10+
Data Processing Pandas, NumPy
Machine Learning XGBoost, Scikit-learn
Visualization Matplotlib, Seaborn, Plotly
Dashboard & Simulation Taipy (stateful, scenario-ready)
Notebooks Jupyter
Version Control Git + GitHub

๐Ÿ—๏ธ Architecture

Raw CSV Data โ†’ Preprocessing โ†’ Feature Engineering โ†’ XGBoost Model
                                                           โ†“
                                                   30-Day Forecasts
                                                           โ†“
                                           Inventory Optimization Engine
                                           (Safety Stock, Reorder Point, EOQ)
                                                           โ†“
                                              streamlit Interactive Dashboard
                                              (Charts + Scenario Simulation)

๐Ÿ“ Folder Structure

Retail-Sales-Forecasting-Inventory-Optimization/
โ”œโ”€โ”€ data/raw/              # Synthetic dataset
โ”œโ”€โ”€ data/processed/        # Cleaned + featured data
โ”œโ”€โ”€ notebooks/             # Jupyter EDA and modeling notebooks
โ”œโ”€โ”€ src/                   # Modular Python source code
โ”œโ”€โ”€ models/                # Saved ML models (.pkl)
โ”œโ”€โ”€ outputs/               # Charts, forecasts, recommendations
โ”œโ”€โ”€ app/                   # streamlit dashboard
โ”œโ”€โ”€ images/                # Screenshots for README
โ”œโ”€โ”€ reports/               # Business summary
โ”œโ”€โ”€ main.py                # Run full pipeline
โ””โ”€โ”€ requirements.txt

โš™๏ธ Installation

# Clone repository
git clone https://github.com/YOUR_USERNAME/Retail-Sales-Forecasting-Inventory-Optimization.git
cd Retail-Sales-Forecasting-Inventory-Optimization

# Create virtual environment
python -m venv retail_env
source retail_env/bin/activate  # Windows: retail_env\Scripts\activate

# Install dependencies
pip install -r requirements.txt

๐Ÿš€ How to Run

# Run full pipeline (data โ†’ model โ†’ inventory โ†’ charts)
python main.py

# Launch interactive streamlit dashboard
cd app && python dashboard.py
# โ†’ Open http://localhost:5000

๐Ÿ“Š Dataset Details

Feature Description
Rows ~109,500 daily sales records
Time Period January 2021 โ€“ January 2024 (3 years)
Stores 5 (Mumbai, Delhi, Bangalore, Chennai, Hyderabad)
Products 20 across 5 categories
Synthetic Patterns Seasonality, weekend effects, festival spikes, stockouts

๐Ÿค– Model Performance

Model RMSE MAE MAPE
XGBoost ~4.2 ~3.1 ~8.3%
Random Forest ~5.1 ~3.8 ~10.2%

MAPE < 15% is considered good for retail demand forecasting.


๐Ÿ“ฆ Inventory Optimization Formulas

Safety Stock  = Z ร— ฯƒ_demand ร— โˆš(lead_time)
Reorder Point = (avg_daily_demand ร— lead_time) + safety_stock
EOQ           = โˆš(2 ร— annual_demand ร— ordering_cost / holding_cost)

๐Ÿ–ผ๏ธ Screenshots

Dashboard

Dashboard

Monthly Sales Trend

Sales Trend

Forecast vs Actual

Forecast

Reorder Recommendations Table

Reorder Table

Inventory Health

Inventory Status


๐Ÿงช Simulation Workflow

  1. Generate 3-year synthetic retail dataset
  2. Clean and preprocess data (handle nulls, outliers, types)
  3. Engineer 25+ features (lag, rolling, seasonality, price)
  4. Train XGBoost forecasting model (time-series split)
  5. Compute safety stock, reorder points, EOQ per product
  6. Launch streamlit dashboard and test what-if scenarios

๐Ÿ”ฎ Future Improvements

  • Multi-store ensemble forecasting
  • Real-time dashboard with live data feed
  • Prophet model for better trend+seasonality decomposition
  • Promotional impact modeling (price elasticity)
  • Weather and event-based demand adjustment
  • ERP system integration (SAP/Oracle)
  • Anomaly detection for unusual sales spikes

๐ŸŽ“ Learning Outcomes

  • Time-series feature engineering for ML
  • XGBoost regression for demand forecasting
  • Operations research inventory formulas (EOQ, ROP, Safety Stock)
  • streamlit for building stateful business dashboards
  • End-to-end ML pipeline design
  • Professional GitHub documentation

๐Ÿ‘ค Author

[CH S K CHAITANYA]

Open to Data Analyst, Business Analyst, Retail Analytics, and Data Science roles.

About

Description An AI-powered retail analytics platform that combines XGBoost demand forecasting with operations research to optimize inventory. It automates Reorder Point (ROP) and EOQ calculations via an interactive Streamlit dashboard to prevent stockouts and overstocking.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages