Comprehensive research exploring machine learning models for predicting retail demand using the M5 Competition Dataset from Walmart, featuring hierarchical forecasting and deep learning approaches.
github.com/pompos02/M5-CompetitionDemandForecastingThis project, based on my thesis "Demand Forecasting in Retail", investigates multiple forecasting approaches ranging from traditional statistical methods to deep learning models. The research addresses the critical business challenge of inventory management and demand prediction across hierarchical sales data.
The project leverages the M5-Competition Dataset, one of the most comprehensive real-world retail forecasting challenges, featuring 42,840 hierarchical time series from Walmart stores across the United States spanning over 5 years of daily sales data.
The dataset enables analysis at 12 aggregation levels:

Figure: M5 Dataset hierarchical structure showing organization from total sales down to individual product-store combinations

Figure: Overall sales trends showing clear upward trajectory with seasonal patterns

Figure: Sales comparison across states showing California's dominance in sales volume

Figure: Product category comparison showing FOODS as the dominant category

Figure: Individual store performance showing significant variations within and across states

Figure: Sales patterns across departments showing FOODS_3 dominance

Annual seasonal patterns

Weekly patterns showing weekend dominance

Figure: State-specific seasonal patterns after trend removal and scaling
Baseline statistical approach using 28-day lag features
Holt-Winters method with additive seasonality
Gradient boosted decision trees at multiple aggregation levels:
Global deep learning model with advanced architecture:

Figure: Random Forest feature importance showing price and temporal features as key predictors

Figure: Mutual Information analysis highlighting non-linear relationships between features and sales

Figure: SHAP analysis revealing feature contribution patterns for one-step-ahead sales prediction
| Model | MAE | RMSE | WRMSSE | Rank |
|---|---|---|---|---|
| LSTM | 1.14 | 1.43 | 0.884 | 1st |
| Exp. Smoothing | 1.11 | 1.44 | 0.888 | 2nd |
| LGBM-store | 1.17 | 1.46 | 0.894 | 3rd |
| LGBM-category | 1.14 | 1.46 | 0.898 | 4th |
| Linear Regression | 1.14 | 1.47 | 0.914 | 5th |
| LGBM-item | 1.22 | 1.57 | 0.957 | 6th |

RMSE distribution across models

BoxPlot revealing model stability

MAE distribution patterns

MAE BoxPlot comparison
This comprehensive study demonstrates that deep learning approaches (LSTM) achieve superior overall performance for retail demand forecasting, approaching top M5 competition results. However, traditional methods like Exponential Smoothing remain highly competitive with significant advantages in computational efficiency and interpretability.
The research provides practical guidance for model selection based on specific business contexts, balancing accuracy requirements, computational constraints, and interpretability needs. The achieved results validate the effectiveness of the implemented methodology and provide valuable insights for real-world retail forecasting applications.