A comparative study of Linear Regression, Random Forest, and XGBoost on the Rossmann Store Sales dataset — daily sales for 1,115 German drugstores over 2.5 years (Jan 2013 – Jul 2015, ~1M transactions). The tuned XGBoost achieves a 6-week-ahead test-set R² of 0.89 (vs 0.26 for the linear baseline), with time-series cross-validation confirming the result holds across chronological folds.
Test set: last 6 weeks of available data (chronologically held out, not random).
| Model | MAE (€) | RMSE (€) | R² (test) | R² (train) |
|---|---|---|---|---|
| Linear Regression (baseline) | 1,953.82 | 2,632.51 | 0.2573 | 0.2174 |
| Random Forest (default) | 718.51 | 1,044.50 | 0.8831 | 0.9875 |
| Random Forest (tuned) | 714.91 | 1,038.23 | 0.8845 | 0.9882 |
| XGBoost (default) | 981.99 | 1,339.32 | 0.8078 | 0.8632 |
| XGBoost (tuned) | 702.53 | 1,016.45 | 0.8893 | 0.9634 |
5-fold time-series cross-validation (TimeSeriesSplit, not random KFold) on a 200K-row sample:
| Model | R² (mean ± sd) | RMSE (mean ± sd) |
|---|---|---|
| Linear Regression | 0.2165 ± 0.0059 | €2,750.66 ± €14.19 |
| XGBoost (tuned) | 0.9020 ± 0.0240 | €965.30 ± €109.63 |
StoreType_bis the single most important feature (~27%). Type-B stores have a categorically different sales profile from the rest — visible directly in the EDA, where their average daily sales dwarf the other types.Promois #2 (~12%). A simple binary flag, but EDA shows it roughly doubles mean daily sales when active.CompetitionDistanceandPromo2matter — both modulate baseline sales materially.- The Linear Regression baseline is fundamentally inadequate (R² ≈ 0.26). Sales effects in this domain are non-linear and interaction-heavy: the impact of a promotion depends on store type, day of week, holiday status, etc. A tree ensemble is the right tool.
- True time-series forecasting, not transaction-level regression: the test set is 6 weeks of future days the model has never seen — the realistic setting for actual deployment.
- Three-model benchmarking (LR / RF / XGBoost) with hyperparameter tuning on the two tree models.
- Time-series cross-validation rather than random KFold — random splits leak future information into training and inflate scores; we don't do that.
Customersexcluded as a feature to avoid target leakage (in the real Rossmann competition, customer count is also a target).
.
├── Sales_Forecasting_ML.ipynb # Main notebook — open this
├── train.csv, store.csv # Auto-downloaded via Kaggle API (not in git)
├── images/ # Generated plots used in this README
├── rossmann_xgb_tuned.joblib # Saved best model (regenerated by notebook; not in git)
├── requirements.txt # Python dependencies
├── project_report.md # Final project report
├── LICENSE # MIT License
└── README.md # This file
pip install -r requirements.txtThe notebook auto-downloads the dataset using the Kaggle API. To enable this:
- Go to https://www.kaggle.com/settings/api
- Click Create New Token — provide any name (e.g., "laptop")
- Copy the token shown
- Save it to one of:
- Linux / macOS:
~/.kaggle/access_token - Windows:
C:\Users\<YourUser>\.kaggle\access_token
- Linux / macOS:
- Accept the competition rules at https://www.kaggle.com/c/rossmann-store-sales/rules
jupyter notebook Sales_Forecasting_ML.ipynbThen Cell → Run All. The notebook will auto-download the data on the first run.
| Step | Time on a modern laptop |
|---|---|
| Data loading & EDA | < 1 min |
| Linear Regression | ~ 5 sec |
| Random Forest (default, 50 trees) | ~ 30 sec |
| RF GridSearchCV (12 combos × 3 folds, 200K-row sample) | 4–6 min |
| RF refit on full data | ~ 1 min |
| XGBoost (default + GridSearchCV + refit) | ~ 90 sec |
| Time-series 5-fold CV | ~ 1 min |
| Total | **~ 9–12 min** |
Python 3.9+ · pandas · numpy · scikit-learn · xgboost · matplotlib · seaborn · joblib · Jupyter Notebook
This project was originally implemented on the Superstore Sales Dataset. That earlier version is preserved as a tagged release: v1.0-superstore. The current main branch uses the Rossmann dataset, which is a true time-series forecasting problem with richer auxiliary features (promotions, holidays, competitor data) — a better fit for both the project name and the task.
MIT — submitted as an internship project deliverable, free for educational reuse.


