Skip to content

ShreyamMajumdar/ECommerce-Orders-Prediction

Repository files navigation

📦 Number of Orders Prediction -- E-Commerce

Python Status

📌 Overview

A machine learning project that predicts the number of customer orders an e-commerce store will receive on any given day using historical patterns, pricing, discounts and marketing campaign data.

🎯 Objective

  • Predict daily order volumes accurately
  • Help businesses optimize inventory and staffing
  • Compare multiple ML models to find the best predictor
  • Provide data-driven business recommendations

📂 Project Structure

orders_project/
│
├── data/
│   ├── orders_raw.csv
│   ├── orders_clean.csv
│   └── predictions.csv
│
├── outputs/
│   └── (10 charts saved here)
│
├── 01_generate_data.py
├── 02_data_cleaning.py
├── 03_eda.py
├── 04_model_training.py
└── 05_insights.py

📊 Dataset

  • Type: Synthetically generated -- simulates real e-commerce patterns
  • Size: 1095 rows -- 3 years of daily data (2021-2023)
  • Target Column: num_orders -- total orders received per day

🛠️ Libraries Used

Library Purpose
pandas Data manipulation and feature engineering
numpy Numerical computing and data generation
matplotlib All charts and visualizations
seaborn Correlation heatmaps
scikit-learn Linear Regression, Random Forest, metrics
xgboost XGBoost gradient boosting model
pickle Save and load trained models

⚙️ Feature Engineering

Feature Description
lag_1 Orders from previous day
lag_7 Orders from same day last week
rolling_avg_7 7-day moving average of orders
is_month_start First 5 days of month flag
is_month_end Last 5 days of month flag
quarter Business quarter (Q1-Q4)
week_of_year Week number (1-52)

🤖 Models Compared

Model Description
Linear Regression Baseline -- fits a straight line through data
Random Forest Ensemble of 100 decision trees
XGBoost Sequential gradient boosting -- best performer

📈 Key Findings

  • XGBoost achieved the best accuracy with lowest RMSE
  • Marketing campaigns boosted daily orders by 25-40%
  • Weekend orders were 15-20% higher than weekdays
  • October to December was the busiest quarter (festive season)
  • lag_1 (yesterday's orders) was the single most important feature

💡 Business Recommendations

  1. Run campaigns in February-May to lift slow months
  2. Increase delivery staff on Fridays for weekend rush
  3. Complete inventory buildup by September for festive season
  4. Use targeted discounts only on Tuesday and Wednesday
  5. Deploy XGBoost every Monday to forecast the coming week

🚀 How to Run

pip install pandas numpy matplotlib seaborn scikit-learn xgboost
 
python 01_generate_data.py
python 02_data_cleaning.py
python 03_eda.py
python 04_model_training.py
python 05_insights.py

About

Number of Orders Prediction using ML -- Random Forest and XGBoost

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages