Skip to content

Monthly demand forecasting using moving average and exponential smoothing in Python.

Notifications You must be signed in to change notification settings

parniariazat/demand-forecasting-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demand Forecasting (Python)

Project Overview

This project forecasts monthly product demand using simple time-series methods. The goal is to demonstrate practical forecasting techniques for inventory and supply chain planning.

Two models are implemented and compared:

  • Moving Average
  • Simple Exponential Smoothing

The best-performing model is then used to forecast future demand.


Dataset

The original dataset contains daily demand data for multiple SKUs.
The data was aggregated into monthly demand for a single product: SKU-004.


Methodology

1. Train–Test Split

  • First 9 months: training data
  • Last 3 months: test data

This allows evaluation of model accuracy on unseen data.


2. Forecasting Models

Moving Average

A 3-month moving average is used:

Forecast = average of last 3 months

Exponential Smoothing

Simple exponential smoothing with:

α = 0.3

This method gives more weight to recent observations.


3. Model Evaluation

Two error metrics are used:

  • MAE (Mean Absolute Error)
  • MAPE (Mean Absolute Percentage Error)
Model MAE MAPE
Moving Average 24.10 3.83%
Exponential Smoothing 20.98 3.32%

The exponential smoothing model performed better.


Forecast Results

Using the best model, the forecasted demand is:

Month Forecast
Jan 2026 612 units
Feb 2026 612 units
Mar 2026 612 units

Project Structure

demand-forecasting-python/
│
├── data/
│   └── inventory_sales_daily.xlsx
│
├── outputs/
│   ├── monthly_series_SKU-004.xlsx
│   ├── monthly_series_SKU-004.png
│   ├── model_comparison_SKU-004.xlsx
│   ├── forecast_test_comparison_SKU-004.png
│   └── future_forecast_SKU-004_*.xlsx
│
├── demand_forecasting_report.pdf
├── demand_forecasting.py
├── requirements.txt
└── README.md

Tools Used

  • Python
  • pandas
  • numpy
  • matplotlib
  • Excel

How to Run

  1. Install dependencies:
pip install -r requirements.txt
  1. Run the script:
python demand_forecasting.py

Outputs will be saved in:

outputs/

Author

Parnia Riazat

About

Monthly demand forecasting using moving average and exponential smoothing in Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages