Skip to content

This project aims to forecast weekly sales for Walmart stores using machine learning techniques. By analyzing historical sales data with store, department, and holiday information, we build models that predict future weekly sales with improved accuracy.

Notifications You must be signed in to change notification settings

sabin74/Sales-Forecasting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏪 Walmart Weekly Sales Forecasting

📘 Project Overview

This project aims to forecast weekly sales for Walmart stores using machine learning techniques.
By analyzing historical sales data with store, department, and holiday information, we build models that predict future weekly sales with improved accuracy.


📂 Dataset Description

1. Train Dataset

  • Contains historical weekly sales records.
  • Columns:
    • Store: Store number
    • Dept: Department number
    • Date: Week date
    • IsHoliday: Whether the week contains a special holiday
    • Weekly_Sales: Target variable (total sales for that week)

2. Features Extracted

After preprocessing and feature engineering:

  • Lag features: lag_1, lag_2, lag_3, lag_4, lag_52
  • Rolling mean features: rolling_mean_4, rolling_mean_12
  • Temporal features: Year, Month, Week, Day
  • Holiday feature: IsHoliday (encoded)
  • Scaled features using MinMaxScaler

3. Test Dataset

  • Includes same features except Weekly_Sales (to be predicted).

⚙️ Project Workflow

1. Data Preprocessing

  • Loaded train and test data.
  • Converted Date column to datetime.
  • Sorted data by Store, Dept, Date.
  • Merged datasets for consistent feature generation.
  • Created lag and rolling mean features to capture past sales trends.

2. Feature Engineering

  • Extracted time-based features (Month, Week, Year).
  • Added historical sales behavior using lag & rolling averages.
  • Scaled numerical features using MinMaxScaler.

3. Data Splitting

  • Split train dataset into:
    • Train (70%)
    • Validation (15%)
    • Test (15%)

🤖 Model Training

Trained multiple regression models to predict Weekly_Sales.

Model Description Status
Linear Regression Baseline model
Random Forest Regressor Ensemble tree-based model
Decision Tree Regressor Simple tree model
Support Vector Machine (RBF) Kernel-based regression
XGBoost Regressor Gradient boosting model

🔍 Model Evaluation

Metrics Used:

  • R² Score
  • Mean Absolute Error (MAE)
  • Root Mean Squared Error (RMSE)

Evaluation Workflow:

  1. Trained models on training data.
  2. Predicted on validation and test sets.
  3. Compared all models’ performance.

📊 Visualization

Actual vs Predicted Plot

Shows how closely the model predictions align with actual sales trends over time.

💾 Model Saving

All trained models and scaler were serialized using pickle for future predictions.

🧠 Prediction on Test Data

Since the test dataset lacks Weekly_Sales, lag and rolling features were generated using the combined train+test data.

About

This project aims to forecast weekly sales for Walmart stores using machine learning techniques. By analyzing historical sales data with store, department, and holiday information, we build models that predict future weekly sales with improved accuracy.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published