Skip to content

End-to-end sales forecasting using Holt-Winters exponential smoothing with automated trend detection, rolling & direct predictions, and PDF reporting.

Notifications You must be signed in to change notification settings

ghfri-code/Sales-Forecasting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงญ Sales Forecasting & Rolling Holt-Winters (Rossmann Case Study)

This project demonstrates time series forecasting using both rolling and direct prediction strategies based on the Holt-Winters Exponential Smoothing model. It applies to the Rossmann Store Sales dataset and includes data exploration, automatic trend & seasonality detection, forecast evaluation, and automated PDF reporting.


๐Ÿ“Š Project Overview

The main objective of this project is to:

  • Analyze sales patterns at both company and store level.
  • Detect trend and seasonality automatically.
  • Perform rolling forecasts (iterative 7-day predictions) and direct forecasts (30-day batch predictions).
  • Evaluate performance using multiple statistical metrics.
  • Generate a PDF report summarizing results and metrics.

๐Ÿง  Key Features

  • ๐Ÿ“ˆ Exploratory Data Analysis (EDA):
    Includes visualizations of trends, seasonality, promotions, store types, and competition distance.

  • ๐Ÿ” Time Series Analysis:
    Automatically detects trend and seasonality using ACF and decomposition.

  • ๐Ÿ”„ Forecasting Strategies:

    • Rolling Forecast: Iterative 7-day forecast updated every cycle.
    • Direct Forecast: One-time 30-day prediction.
      Both trained using Holt-Winters Exponential Smoothing.
  • ๐Ÿงฎ Performance Evaluation:
    Results include both absolute and relative error metrics:

    Metric Description Unit
    RMSE Root Mean Squared Error Absolute
    Relative RMSE RMSE as % of mean actuals %
    MAE Mean Absolute Error Absolute
    Relative MAE MAE as % of mean actuals %
    MAPE Mean Absolute Percentage Error (Company-level only) %
    Rยฒ Coefficient of Determination -
  • ๐Ÿ“„ Automated Reporting:
    Creates clean, professional reports for both company and store forecasts, including daily forecasted values and performance summary.

  • ๐Ÿฌ Store-Level Analysis:
    Includes example forecasting for an individual store (Store ID = 1).


๐Ÿงฉ Project Structure

๐Ÿ“ data/
 โ”œโ”€โ”€ rossmann/
 โ”‚   โ”œโ”€โ”€ train.csv
 โ”‚   โ”œโ”€โ”€ store.csv
๐Ÿ“ report/
 โ”œโ”€โ”€ sales_forecast_report_company.pdf
 โ”œโ”€โ”€ sales_forecast_report_store1.pdf
 โ”œโ”€โ”€ forecast_comparison_company.png
๐Ÿ“„ Sales_Forecasting.ipynb
๐Ÿ“„ requirements.txt
๐Ÿ“„ README.md

โš™๏ธ Installation & Setup

  1. Clone this repository

    git clone https://github.com/ghfri-code/Sales-Forecasting.git
    cd Sales-Forecasting
  2. Install dependencies

    pip install -r requirements.txt
  3. Add dataset
    Download the Rossmann Store Sales dataset and place it under:

    data/rossmann/train.csv
    data/rossmann/store.csv
    
  4. Run the notebook

    jupyter notebook Sales_Forecasting.ipynb

๐Ÿ“ˆ Example Visualizations

  • Daily sales trend with a 30-day moving average
  • Sales by day of week and monthly sales trend
  • Top 10 stores by sales
  • Promotion impact analysis
  • Store type & competition distance analysis

๐Ÿงฎ Forecasting Process

  1. Data Preparation: Load and merge datasets; handle missing days and promotions
  2. Trend & Seasonality Detection: Auto-detect seasonal period using ACF and seasonal_decompose
  3. Forecast Generation: Apply both rolling and direct Holt-Winters forecasting (statsmodels.tsa.holtwinters.ExponentialSmoothing)
  4. Model Evaluation: Compute RMSE, MAE, MAPE, and Rยฒ for comparison
  5. Visualization & Reporting: Save forecast plot as PNG and generate PDF summary report

๐Ÿงฐ Tech Stack

  • Python ๐Ÿ
  • pandas, numpy, matplotlib, seaborn โ€“ data handling & visualization
  • statsmodels โ€“ time series modeling (Holt-Winters)
  • scikit-learn โ€“ evaluation metrics
  • fpdf โ€“ PDF report generation

๐Ÿ“œ Requirements

pandas
numpy
matplotlib
statsmodels
scikit-learn
fpdf

๐Ÿš€ Future Improvements

  • Integrate Prophet and XGBoost for hybrid forecasts
  • Add automated hyperparameter tuning for seasonal components
  • Implement automated parameter tuning for seasonal periods
  • Add interactive dashboards (Streamlit / Plotly)

About

End-to-end sales forecasting using Holt-Winters exponential smoothing with automated trend detection, rolling & direct predictions, and PDF reporting.

Topics

Resources

Stars

Watchers

Forks