Rossmann daily sales forecast · Decision tree

Predicts the daily sales (EUR) of any of the 1,115 Rossmann drugstores from what is known in advance: the store, the date, whether a promotion runs and the holidays. It does not use the number of customers of that day.

A single regression tree (max depth 18, at least 20 store-days per leaf).

Metric (last 6 weeks, held out, n=40,282 store-days) Value
R² 0.842
RMSPE (Kaggle metric) 0.176
RMSE 1,216 EUR
MAE 844 EUR

For reference, predicting each store's average for that weekday gives R² 0.696 and RMSPE 0.224.

Actual vs predicted

Data: Kaggle "Rossmann Store Sales" (train.csv + store.csv), read from AiiN-aini/rossmann-store-sales. Open days with sales only. Train: 2013-01-01 to 2015-06-19 (804,056 store-days). Test: 2015-06-20 to 2015-07-31: the last 6 weeks, never seen by the model or by the per-store statistics.

Target: log1p(sales); predictions are turned back into euros with expm1.

Features (21): calendar (weekday, day, month, year, week and day of year, month start/end), promotion and holiday flags, store type, assortment, competition distance and age, Promo2 status, and four per-store statistics from the training period (store_stats.csv).

Usage

The features are built by forecast/features.py in the project repository; scikit-learn must be version 1.9.1.

import joblib, numpy as np, pandas as pd
from huggingface_hub import snapshot_download
from forecast.features import build_features   # from the project repository

path = snapshot_download("jramduran/rossmann-sales-decision-tree")
model = joblib.load(f"{path}/model.joblib")   # only load pickles you trust
stats = pd.read_csv(f"{path}/store_stats.csv")
day = pd.DataFrame([{"store": 336, "date": "2015-08-07", "promotion": 1,
                     "state_holiday": 0, "school_holiday": 0}])
X = build_features(day, stats)
features = ["day_of_week", "day", "month", "year", "week_of_year", "day_of_year", "is_month_start", "is_month_end", "promotion", "state_holiday", "school_holiday", "store_type", "assortment", "competition_distance_log", "competition_open_months", "promo2_active", "promo2_month", "store_mean_log_sales", "store_dow_log_sales", "store_promo_lift", "store_mean_log_customers"]
print(np.expm1(model.predict(X[features])))   # EUR
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train jramduran/rossmann-sales-decision-tree