Skip to content

saktronX/FUTURE_ML_01

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FUTURE_ML_01

📈 Sales Demand Forecasting using Machine Learning

Predicting future retail sales using historical data and XGBoost Regression.

Python Pandas Scikit-Learn XGBoost Status


📌 Project Overview

Sales forecasting plays a crucial role in retail businesses by helping estimate future demand. Accurate predictions enable businesses to optimize inventory, reduce stock shortages, improve promotional planning, and make informed operational decisions.

This project develops a Sales Demand Forecasting model using historical retail sales data and the XGBoost Regressor. The workflow includes data preprocessing, exploratory data analysis (EDA), feature engineering, model training, evaluation, and forecasting.


🎯 Objectives

  • Analyze historical sales trends
  • Perform data preprocessing and feature engineering
  • Build a machine learning forecasting model
  • Predict future sales
  • Evaluate model performance
  • Generate business insights for decision-making

🗂 Dataset

The project uses the Store Sales Forecasting Dataset containing historical sales records.

Features

Feature Description
id Record ID
date Date of transaction
store_nbr Store number
family Product category
sales Sales value (Target Variable)
onpromotion Number of promoted products

🛠 Technologies Used

  • Python
  • Pandas
  • NumPy
  • Matplotlib
  • Scikit-Learn
  • XGBoost
  • Jupyter Notebook

📂 Project Structure

FUTURE_ML_01
│
├── data/
│   └── train.csv
│
├── images/
│   ├── sales_trend.png
│   ├── feature_importance.png
│   ├── forecast_2017.png
│   └── actual_vs_predicted.png
│
├── models/
│
├── notebooks/
│   └── Sales_Demand_Forecasting.ipynb
│
├── .gitignore
└── README.md

🔄 Machine Learning Workflow

1️⃣ Data Loading

  • Loaded historical retail sales dataset
  • Checked data structure
  • Verified missing values
  • Inspected feature types

2️⃣ Exploratory Data Analysis

Performed analysis including:

  • Sales trend over time
  • Product family analysis
  • Distribution of sales
  • Business observations

3️⃣ Feature Engineering

Created time-based features including:

  • Year
  • Month
  • Day
  • Day of Week
  • Quarter
  • Week of Year

These features help the model capture seasonal demand patterns.


4️⃣ Train-Test Split

Since this is a forecasting problem, a time-based split was used.

Training Data:

  • 2013–2016

Testing Data:

  • 2017

This prevents future information from leaking into training.


5️⃣ Model Development

Model Used:

XGBoost Regressor

Reasons for choosing XGBoost:

  • Handles nonlinear relationships
  • High prediction accuracy
  • Efficient for structured/tabular datasets
  • Excellent performance for regression problems

📊 Model Performance

Metric Score
MAE 137.04
RMSE 401.45
R² Score 0.9122

The model explains over 91% of the variation in sales, indicating strong predictive performance.


📈 Visualizations

Sales Trend

Sales Trend


Feature Importance

Feature Importance


Actual vs Predicted Sales

Actual vs Predicted


Forecasted Daily Sales (2017)

Forecast

💡 Business Insights

The analysis revealed several key findings:

  • Product category is the most influential factor affecting sales.
  • Promotional campaigns significantly increase demand.
  • Sales vary considerably across stores.
  • Seasonal and calendar-based patterns influence purchasing behavior.
  • Historical trends provide strong predictive power for future demand.

🚀 Business Applications

This forecasting system can help businesses:

  • Improve inventory management
  • Reduce stock shortages
  • Minimize excess inventory
  • Optimize promotional campaigns
  • Improve staffing decisions
  • Support budgeting and financial planning

📌 Future Improvements

Possible enhancements include:

  • Hyperparameter tuning using GridSearchCV
  • Cross-validation with TimeSeriesSplit
  • Incorporating holiday and weather data
  • Deploying the model using Streamlit
  • Real-time sales prediction dashboard
  • Deep Learning models (LSTM)

🏆 Results

✔ Data preprocessing completed

✔ Exploratory Data Analysis performed

✔ Feature engineering implemented

✔ XGBoost forecasting model developed

✔ Model evaluated successfully

✔ Business insights generated

✔ Future sales forecast visualized


👨‍💻 Author

Saksham Verma

GitHub: https://github.com/saktronX

LinkedIn: (Add your LinkedIn profile link here)


📜 Internship

This project was completed as part of the Future Interns Machine Learning Internship (Task 1 – Sales Demand Forecasting).

About

machine-learning xgboost sales-forecasting time-series python pandas scikit-learn data-analysis forecasting future-interns

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages