Instructions to use jramduran/rossmann-sales-random-forest with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use jramduran/rossmann-sales-random-forest with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("jramduran/rossmann-sales-random-forest", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Rossmann daily sales forecast · Random forest
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.
60 regression trees (max depth 20), each grown on half of the rows and half of the features.
| Metric (last 6 weeks, held out, n=40,282 store-days) | Value |
|---|---|
| R² | 0.891 |
| RMSPE (Kaggle metric) | 0.142 |
| RMSE | 1,007 EUR |
| MAE | 684 EUR |
For reference, predicting each store's average for that weekday gives R² 0.696 and RMSPE 0.224.
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-random-forest")
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
- -
