This project is a Sales Prediction Tool that enables users to analyze and predict customer sales. It provides a fully customizable data preprocessing pipeline and machine learning hyperparameter tuning via a Flask and Angular interface.
- Exploratory Data Analysis (EDA) notebooks are available:
- Key analysis questions addressed:
- Ordered plot of total transactions per customer (most to least active)
- Monthly transaction frequency for a given product ID (for 2018)
- Top 5 highest-selling products over the last six months
- Data seasonality effect
The pipeline consists of three transformation levels:
- Level 1: Load and clean data (remove duplicates, transform date format)
- Level 2: Compute monthly transactions per customer & define the target variable
- Level 3: Compute rolling features and lag features
- Fully configurable via
config/processing_config.json
- Ensures model robustness by simulating past performance
- Time-based data splits for training, validation, and testing:
Split | Training Period | Validation Period | Testing Period |
---|---|---|---|
Split 1 | 2017-01 to 2017-12 | 2018-01 to 2018-03 | 2018-04 to 2018-06 |
Split 2 | 2017-01 to 2018-03 | 2018-04 to 2018-06 | 2018-07 to 2018-09 |
Split 3 | 2017-01 to 2018-06 | 2018-07 to 2018-09 | 2018-10 to 2018-12 |
Split 4 | 2017-01 to 2018-09 | 2018-10 to 2018-12 | 2019-01 to 2019-03 |
Split 5 | 2017-01 to 2018-12 | 2019-01 to 2019-03 | 2019-04 to 2019-06 |
Split 6 | 2017-01 to 2019-03 | 2019-04 to 2019-06 | 2019-07 to 2019-09 |
- Various Machine Learning algorithms & clustering methods are supported
- Fully configurable via
config/training_config.json
- Features can be selected via
config/features.json
- Forecasts sales using trained models
- Allows configuration of:
- Number of models used for aggregation
- Aggregation function (e.g., weighted method prioritizes recent models)
- Configurable via
config/inference_config.json
- Web interface to edit configurations and run training pipeline
Make sure you have the following installed:
- Python
- Node.js (Optional, for UI)
- Angular CLI (Optional, for UI)
- Clone the repository:
git clone https://github.com/Lahdhirim/ML-sales-prediction-tool.git cd ML-sales-prediction-tool
- Install dependencies:
- Python packages:
pip install -r requirements.txt
- Angular UI (Optional):
cd src/config_editor/angular_ui npm install
- Python packages:
Three execution modes are available:
python main.py train
Or simply:
python main.py
python main.py train_with_ui
python main.py inference
Generated outputs are stored in data/output
:
raw_predictions.csv
→ Raw sales predictions from backtestingKPIs.xlsx
→ Performance metrics from backtestinginference.csv
→ Predictions during production phase