
Rossmann Store Sales Forecasting with LSTM
Deep learning solution for multivariate time-series forecasting of daily sales data
Timeline
Completed
Role
ML Engineer
Status
CompletedTechnology Stack
Rossmann Store Sales Forecasting with LSTM
A deep learning solution for multivariate time-series forecasting of daily sales data from Rossmann drug stores (2013-2015). The goal is to accurately predict future sales to optimize operational decisions.
Project Overview
This project implements a Stacked LSTM (Long Short-Term Memory) Neural Network to forecast daily sales with high accuracy. The model captures long-term dependencies in sequential sales data and provides reliable predictions for business planning.
Model: Stacked LSTM Neural Network Dataset: Rossmann Store Sales (Focus: Data for Store 1) Performance: R² Score > 0.85
Methodology and Technical Stack
Data Processing
| Step | Detail | | :--- | :--- | | Data Cleaning | Handled missing values (NaN replaced with 0). Filtered out all days when the store was closed (Open = 0). | | Feature Engineering | Extracted temporal features: Month, Year, DayOfWeek, and WeekOfYear. | | Feature Scaling | Features were scaled using MinMaxScaler for optimal LSTM performance. | | Sequence Creation | Data was reshaped into sequences of 30 timesteps (days) to serve as the look-back window for the model. |
Model Architecture
The model uses a Stacked LSTM design, effective for capturing long-term dependencies in sequential data.
| Layer Type | Units/Size | Notes | | :--- | :--- | :--- | | LSTM (Layer 1) | 100 | Captures sequential patterns. | | LSTM (Layer 2) | 100 | Captures deeper temporal features. | | Dropout | 20% | Applied after each LSTM layer for regularization. | | Output | 1 | Final prediction of the next day's Sales. | | Optimization | Adam optimizer, Loss: MSE (Mean Squared Error). | - |
Model Performance and Evaluation
The model showed excellent performance on the unseen test data.
Key Metrics
| Metric | Value | Interpretation | | :--- | :--- | :--- | | R² Score | > 0.85 | The model explains over 85% of the variance in sales. | | RMSE | ≈ 1,215 | Root Mean Squared Error (deviation in Euros). | | MAE | ≈ 705 | Mean Absolute Error (average error in Euros). |
Prediction Quality
- Training Dynamics: Validation Loss tracked the Training Loss closely, confirming the model generalized well.
- Prediction vs. Actual: The scatter plot showed predictions clustering tightly around the ideal 45° line, indicating low residual error across the sales range.
Future Forecasting
The trained model generated a stable 30-day forecast that smoothly continues the historical sales trend, providing a reliable baseline for the store's sales outlook.
Tech Stack
- Language: Python
- Deep Learning: TensorFlow, Keras
- Data Processing: Pandas, Scikit-learn
- Visualization: Matplotlib, Seaborn
Installation and Setup
Create Virtual Environment
python -m venv sales_env
source sales_env/bin/activate # On Windows: sales_env\Scripts\activateInstall Dependencies
pip install -r requirements.txtRequired Libraries
- TensorFlow >= 2.0
- Pandas >= 1.0
- NumPy >= 1.18
- Scikit-learn >= 0.24
- Matplotlib >= 3.0
- Seaborn >= 0.11
How to Run
- Clone the Repository:
git clone https://github.com/SHREY275/rossmann-sales-forecasting.git
cd rossmann-sales-forecasting-
Prepare the Data: Place the Rossmann dataset in the
data/directory. -
Run the Notebook:
jupyter notebook rossmann_forecasting.ipynb- Generate Predictions: The notebook will train the model and generate 30-day sales forecasts.
Key Features
- Stacked LSTM architecture for capturing temporal dependencies
- Comprehensive data preprocessing and feature engineering
- MinMax scaling for optimal neural network performance
- 30-day rolling window for sequence creation
- Dropout regularization to prevent overfitting
- Detailed performance metrics and visualization
- 30-day future sales forecast
Results Summary
- Successfully predicted daily sales with R² > 0.85
- RMSE of approximately 1,215 Euros
- MAE of approximately 705 Euros
- Model generalizes well with minimal overfitting
- Reliable baseline for operational planning
Repository: github.com/SHREY275/Sales_ml_prj
