# alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms architecture

> Architecture diagram of the GitHub repository alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms
- Repository: https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms

## Overview

##### Project type and purpose
- This is a standalone data-science pipeline written in Python for demand forecasting in a supply-chain context.
- It ingests historical sales data (CSV), applies a battery of time‐series and machine‐learning algorithms, uses an ensemble strategy to select the best forecasts, and emits results in multiple formats (JSON, CSV, HTML), plus an Excel playbook for manual visualization.

##### File structure
- Model_Implementation/Code/Sales_Forecasting.py: main Python script containing the entire pipeline
- Model_Implementation/Input_Data_File/Sales_data.csv: raw historical data of SKUs
- Model_Implementation/Output Files/: generated artifacts including forecast CSVs, JSON summaries, HTML report
- Visualization/Forecast_Sales_Playbook.xlsx: Excel workbook for interactive review of forecasts
- README.md: full description of objectives, algorithms, evaluation metrics, and research questions

##### Examining the README
- Confirms the use of multiple time-series (AR, ARMA, ARIMA, SES, HWES) and ML algorithms (linear models, tree models, kNN, SVM regression) with an ensemble layer (AdaBoost, Bagging, RF, ET, GBM).
- Indicates evaluation metrics (RMSE, MAPE, forecast accuracy) and comparison across SKUs.

##### Main components
a. Data Source
- Input CSV file stored locally or in a data lake
b. Data Preprocessing
- Reading CSV, cleaning, ABC classification, ACF/PACF calculations
c. Modeling Layer
- Time-Series Module: AR, ARMA, ARIMA, SMA, SES, HWES
- ML Module: LR, Lasso, Ridge, Elastic Net, Huber, LLARS, PassiveAggressive, CART, kNN, SVMR
d. Ensemble Engine
- AdaBoost, Bagging, Random Forest, Extra Trees, Gradient Boosting
- Decision integration strategy that picks the best model per SKU
e. Evaluation & Metrics
- Compute RMSE, MAPE, forecast accuracy for each model and for the ensemble
f. Output Generator
- Write forecasts to CSV (forecast_data.csv, all_skus_output.csv, best_models.csv)
- Serialize summary to JSON (Sales_data.json)
- Generate HTML report (Output_html_file.html)
g. Visualization/Playbook
- Populate Forecast_Sales_Playbook.xlsx with results for interactive analysis

##### Architectural patterns and design principles
- Pipeline pattern with modular stages (clean-transform-model-evaluate-report).
- Separation of concerns: each algorithm group in its own subcomponent.
- Pluggable architecture: easy to add new models or metrics.
- Single-entry point (Sales_Forecasting.py) driving the entire orchestration.

##### Key technologies and libraries
- Python 3.x
- pandas for data handling
- statsmodels for time-series
- scikit-learn for ML algorithms and ensemble methods
- matplotlib/seaborn or plotly (implicit for HTML report)
- openpyxl or xlsxwriter for Excel playbook

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Orchestration
    Orchestrator["Sales_Forecasting.py"]:::processing
    click Orchestrator "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Code/Sales_Forecasting.py"

    %% Data Ingestion
    DataSource[/ "Sales_data.csv" /]:::dataSource
    click DataSource "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Input_Data_File/Sales_data.csv"

    Preprocessing["Data Preprocessing\n(CSV Read, Clean, ABC, ACF/PACF)"]:::processing

    Orchestrator --> Preprocessing
    DataSource --> Preprocessing

    %% Modeling Layer
    subgraph "Modeling Layer"
        TSModel["Time-Series Models\n(AR, ARMA, ARIMA, SES, HWES)"]:::model
        MLModel["ML Models\n(LR, Lasso, Ridge, ElasticNet,\nHuber, LLARS, PassiveAggressive,\nCART, kNN, SVMR)"]:::model
    end
    click TSModel "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Code/Sales_Forecasting.py"
    click MLModel "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Code/Sales_Forecasting.py"

    Preprocessing --> TSModel
    Preprocessing --> MLModel

    %% Ensemble
    Ensemble["Ensemble Engine\n(AdaBoost, Bagging,\nRandomForest, ExtraTrees,\nGradientBoosting)"]:::ensemble
    click Ensemble "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Code/Sales_Forecasting.py"

    TSModel --> Ensemble
    MLModel --> Ensemble

    %% Evaluation
    Evaluation["Evaluation & Metrics\n(RMSE, MAPE, Accuracy)"]:::evaluation
    click Evaluation "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Code/Sales_Forecasting.py"

    Ensemble --> Evaluation

    %% Output Generation
    subgraph "Output Generator"
        CSV1[/ "forecast_data.csv" /]:::output
        click CSV1 "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Output Files/forecast_data.csv"
        CSV2[/ "all_skus_output.csv" /]:::output
        click CSV2 "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Output Files/all_skus_output.csv"
        CSV3[/ "best_models.csv" /]:::output
        click CSV3 "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Output Files/best_models.csv"
        JSON[/ "Sales_data.json" /]:::output
        click JSON "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Output Files/Sales_data.json"
        HTML[("Output_html_file.html")]:::report
        click HTML "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Model_Implementation/Output Files/Output_html_file.html"
    end

    Evaluation --> CSV1
    Evaluation --> CSV2
    Evaluation --> CSV3
    Evaluation --> JSON
    Evaluation --> HTML

    %% Visualization
    ExcelReport[("Forecast_Sales_Playbook.xlsx")]:::report
    click ExcelReport "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/Visualization/Forecast_Sales_Playbook.xlsx"

    HTML --> ExcelReport
    CSV1 --> ExcelReport
    CSV2 --> ExcelReport
    CSV3 --> ExcelReport
    JSON --> ExcelReport

    %% Documentation
    README[("README.md")]:::report
    click README "https://github.com/alekhyabhupati/demand-forecasting-models-for-supply-chain-using-statistical-and-machine-learning-algorithms/blob/main/README.md"

    %% Styles
    classDef dataSource fill:#B3DDF2,stroke:#333,stroke-width:1px
    classDef processing fill:#C1E1C1,stroke:#333,stroke-width:1px
    classDef model fill:#C1E1C1,stroke:#333,stroke-width:1px
    classDef ensemble fill:#ADE1F9,stroke:#333,stroke-width:1px
    classDef evaluation fill:#FFD27F,stroke:#333,stroke-width:1px
    classDef output fill:#D7B2D7,stroke:#333,stroke-width:1px
    classDef report fill:#F9D1AD,stroke:#333,stroke-width:1px
```
