Predicting weekly department-level sales across 45 Walmart stores using historical markdown and holiday data β deployed as a live Flask web application.
Retail chains like Walmart face a critical challenge: accurately forecasting sales to optimize inventory, staffing, and supply chain decisions β especially during high-impact holiday seasons.
This project builds an end-to-end machine learning solution to predict weekly store sales using 2+ years of historical data from 45 Walmart stores across different US regions. The model accounts for promotional markdowns, seasonal spikes (Super Bowl, Thanksgiving, Christmas, Labour Day), and store-level features.
- Helps Walmart plan stock levels and warehouse space before high-demand periods
- Identifies which stores and departments are most affected by holiday markdowns
- Enables data-driven decisions on regional promotions and resource allocation
Source: Kaggle β Walmart Store Sales Forecasting
| File | Description |
|---|---|
train.csv |
Historical weekly sales per store & department (Feb 2010 β Oct 2012) |
test.csv |
Target period for prediction |
features.csv |
Store-level features: Temperature, Fuel Price, CPI, Unemployment, MarkDowns |
stores.csv |
Store metadata: type (A/B/C) and size |
Key Challenge: Holiday weeks are weighted 5x higher in evaluation (WMAE metric), making accurate holiday prediction critical.
Walmart-Store-Sales-Forecasting/
βββ data/
β βββ train.csv
β βββ test.csv
β βββ features.csv
β βββ stores.csv
βββ templates/
β βββ index.html # Flask frontend
βββ static/
β βββ style.css
βββ Walmart Store Sales Forecasting.ipynb # Full EDA + Modelling
βββ app.py # Flask application
βββ model.pkl # Serialized trained model
βββ requirements.txt
βββ Dockerfile
- Analyzed seasonal patterns in weekly sales across stores and departments
- Identified holiday spikes β Thanksgiving consistently outperforms Christmas in actual sales
- Found that January sales drop sharply post-holiday season
- Examined impact of external factors: CPI, fuel price, unemployment, temperature
- Extracted time features: Week, Month, Year from date
- Engineered holiday flags for Super Bowl, Labour Day, Thanksgiving, Christmas
- Merged store metadata (type, size) with weekly sales and external features
- Handled missing MarkDown values (up to 4,140 nulls in some columns) using median imputation
- Evaluated multiple regression approaches for time-series forecasting
- Applied Random Forest Regressor as the primary model due to its ability to capture non-linear relationships and feature interactions
- Used cross-validation with time-aware splits to prevent data leakage
WMAE (Weighted Mean Absolute Error) β holiday weeks weighted 5x:
WMAE = (1 / Ξ£wα΅’) Γ Ξ£ wα΅’ |yα΅’ - Ε·α΅’|
- Serialized model using
pickleβmodel.pkl - Built a Flask web app for real-time sales prediction
- Containerized with Docker for portability
- Deployed on web (previously Heroku, migrating to Render)
| Metric | Value |
|---|---|
| Evaluation | WMAE (Weighted MAE) |
| Holiday Weight | 5Γ non-holiday weeks |
| Stores Covered | 45 stores, multiple departments |
| Prediction Period | Weekly |
Key Finding: Holiday markdown events β especially Thanksgiving β are the single strongest predictor of sales spikes. Store type and size also significantly influence baseline weekly sales.
| Category | Tools |
|---|---|
| Language | Python 3.8+ |
| Data Processing | Pandas, NumPy |
| Visualisation | Matplotlib, Seaborn |
| Modelling | Scikit-learn (Random Forest, Linear Regression) |
| Web Framework | Flask |
| Deployment | Docker, Heroku β Render |
| Notebook | Jupyter Notebook |
# Clone the repository
git clone https://github.com/vicky60629/Walmart-Store-Sales-Forecasting.git
cd Walmart-Store-Sales-Forecasting
# Install dependencies
pip install -r requirements.txt
# Run the Flask app
python app.pyThen open http://localhost:5000 in your browser.
docker build -t walmart-forecasting .
docker run -p 5000:5000 walmart-forecasting| Input Form | Prediction Output |
|---|---|
![]() |
![]() |
What worked well:
- Feature engineering around holidays significantly improved prediction accuracy
- Random Forest handled the non-linear interactions between store size, type, and markdown events effectively
Future enhancements:
- Integrate XGBoost / LightGBM for potential performance gains
- Add SARIMA / Prophet for pure time-series baseline comparison
- Build interactive dashboard with Streamlit or Plotly Dash
- Incorporate external data: weather APIs, economic indicators
- Retrain with MLflow for experiment tracking
Vicky Gupta β Data Engineering Analyst @ Accenture (4.5 years) | Aspiring Data Scientist
Skilled in PySpark, ETL pipelines, and end-to-end ML systems. Passionate about building data products that solve real business problems.
This project is licensed under the MIT License β see the LICENSE file for details.
β If you found this project useful, please consider starring the repository!

