Skip to content

KuchikiRenji/Supply-Chain-forecasting-deep-learning

Repository files navigation

Supply Chain Demand Forecasting with Deep Learning

Sales and demand forecasting for supply chain optimization using machine learning and deep learning. Compare Linear Regression, XGBoost, CNN, LSTM, CNN-LSTM, GRU, and Transformer models for inventory and replenishment optimization.


Author & Contact

Author KuchikiRenji
Email KuchikiRenji@outlook.com
GitHub github.com/KuchikiRenji
Discord kuchiki_renji

Table of Contents


Overview

This repository implements supply chain demand forecasting and sales forecasting using both machine learning and deep learning models. The goal is to predict future sales to support:

  • Inventory optimization — match store inventory to demand and reduce storage/rental costs
  • Replenishment optimization — optimize order quantities to minimize warehouse-to-store replenishments and cut warehousing and transportation costs
  • Business model design — identify factors that drive sales for strategy and optimization

The project uses store–item daily sales data (date, store, item, sales) with rich time-based and aggregate features, and compares multiple ML/DL architectures for accuracy and practicality.


Problem Statement

  1. Sales trend understanding — Forecast future sales from historical patterns.
  2. Inventory optimization — Align store inventory with actual demand to reduce storage space and rental cost.
  3. Replenishment optimization — Optimize replenishment quantity per order to minimize the number of replenishments between warehouse and stores (reducing warehousing and transportation costs).
  4. Factor analysis — Find factors that affect sales to design and optimize the business model.

Models Compared

Machine Learning

Model Description
Linear Regression Best-fit linear relationship between dependent and independent variables.
XGBoost Gradient boosted decision trees with regularization and parallel split selection.

Deep Learning

Model Description
CNN Feedforward network effective for time series forecasting.
LSTM Recurrent network that addresses standard RNN limitations.
CNN-LSTM CNN for feature extraction from time series, LSTM for sequence prediction.
GRU Gated recurrent unit with fewer parameters, designed to mitigate vanishing gradients.
Transformer Self-attention over input sequence, weighting importance of each time step.

Project Structure

Supply-Chain-forecasting-deep-learning/
├── README.md
├── Transformer.py              # Transformer model (Keras/TensorFlow)
├── Sales Demand Forecast.ipynb # Main notebook: ML + DL comparison
├── Sales Demand Forecast- Transformer model.ipynb  # Transformer pipeline
├── CNN_MODEL.h5
├── CNN-LSTM_MODEL.h5
├── GRU_MODEL.h5
└── LSTM_MODEL.h5
  • Notebooks: Data loading, feature engineering, training, and evaluation for all models.
  • Transformer.py: Reusable Transformer architecture with configurable look-back, horizon, and attention.
  • Pre-trained models: Saved Keras models (.h5) for CNN, CNN-LSTM, GRU, and LSTM.

Getting Started

Requirements

  • Python 3.7+
  • Libraries: tensorflow (or keras), scikit-learn, pandas, numpy, xgboost, matplotlib, seaborn, plotly

Install core dependencies:

pip install tensorflow scikit-learn pandas numpy xgboost matplotlib seaborn plotly

For the Transformer notebook, ensure parameters.json and utils (e.g. utils.py with rmse, smape, coeff_determination, series_to_supervised) are available in the project root.

Data

The notebooks expect a train dataset with columns: date, store, item, sales. Update the CSV path in the notebook to your own file (e.g. replace the path to train.csv with your dataset location).

Run the notebooks

  1. Open Sales Demand Forecast.ipynb for the full ML/DL comparison (Linear Regression, XGBoost, CNN, LSTM, CNN-LSTM, GRU).
  2. Open Sales Demand Forecast- Transformer model.ipynb for the Transformer-based forecasting pipeline.

Key Results

  • Best performers in this project: XGBoost (ML) and CNN-LSTM (DL).
  • XGBoost: Good forecasts with minimal hyperparameter tuning, works with fewer data/features, includes regularization to limit overfitting and supports fast parallel training.
  • CNN-LSTM: Convolution layers extract features from time series, pooling retains important information, and the LSTM layer models temporal dependencies for accurate next-step prediction.

License

This project is open source. For usage and licensing terms, see the repository license or contact the author.


Keywords: supply chain forecasting, demand forecasting, sales forecasting, deep learning, LSTM, CNN, Transformer, XGBoost, time series, inventory optimization, replenishment optimization, TensorFlow, Keras.

About

Supply chain & sales demand forecasting with ML and deep learning (XGBoost, CNN, LSTM, CNN-LSTM, GRU, Transformer). Inventory and replenishment optimization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors