Downloads · 30 days
0
samuelalex37/olist-delivery-risk-model
olist-delivery-risk-model is a tabular classification model from samuelalex37. Use it for the tabular classification task on the model card, and read the license before you ship it in a product. It is set up for sklearn. The card lists the license as cc-by-nc-sa-4.0.
Predicts whether a Brazilian e-commerce order will be delivered later than the date promised to the customer at checkout.
Downloads · 30 days
0
Access
Public
Updated Jul 28, 2026
Repo size
2.4 MB
Likes
0
Public
Click a slice to open those files.
.joblib1.2 MB · 99%
From the Hugging Face model README
Predicts whether a Brazilian e-commerce order will be delivered later than the date promised to the customer at checkout.
Registered automatically by the project's MLOps pipeline. Live application: Olist Delivery Risk Radar
Measured on 19,294 held-out orders the model never saw during training.
| Metric | Value |
|---|---|
| ROC-AUC | 0.8101 |
| PR-AUC | 0.3354 |
| Recall | 0.5323 |
| Precision | 0.3045 |
| F1 | 0.3874 |
| Brier score | 0.0633 |
| Decision threshold | 0.155 |
| Model | Accuracy | Precision | Recall | F1 | ROC-AUC | PR-AUC |
|---|---|---|---|---|---|---|
| Gradient Boosting | 0.777 | 0.219 | 0.686 | 0.332 | 0.810 | 0.336 |
| Random Forest | 0.845 | 0.273 | 0.551 | 0.365 | 0.799 | 0.330 |
| Logistic Regression | 0.657 | 0.144 | 0.655 | 0.236 | 0.710 | 0.183 |
| "always on time" | 0.919 | — | 0.000 | — | 0.500 | 0.081 |
That last row is the point. Only 8.11% of orders are late, so a model that ignores every input and always answers "on time" scores 91.9% accuracy while catching zero late deliveries. Accuracy is not the metric to judge this on.
Class weighting made the raw model overstate risk by roughly 4.4× — orders it scored "30–40% likely late" were in reality late only 3.4% of the time.
Isotonic calibration corrected this. Mean predicted probability moved from 36.0% to 8.11% against a true rate of 8.11%, and the Brier score improved by about 60% while ROC-AUC was unchanged.
A reading of 20% from this model genuinely means about one order in five.
Not the default 0.5, and not maximum F1 — both assume a missed late delivery costs the same as a false alarm. It doesn't: 54.1% of late deliveries attract a 1–2 star review, against 9.2% of on-time ones.
The shipped threshold of 0.155 minimises
5 × misses + false alarms, reducing expected cost by
about 29% versus taking no action.
import joblib, json, pandas as pd
from huggingface_hub import hf_hub_download
repo = "samuelalex37/olist-delivery-risk-model"
model = joblib.load(hf_hub_download(repo, "model.joblib"))
meta = json.load(open(hf_hub_download(repo, "model_metadata.json")))
columns = meta["numeric_features"] + meta["categorical_features"]
probability = model.predict_proba(pd.DataFrame([order])[columns])[0, 1]
flagged = probability >= meta["decision_threshold"]
model.joblib contains the entire pipeline — imputation, scaling, one-hot
encoding, the classifier and the calibrator — so no preprocessing code is needed
and the transformations cannot drift out of step with the model.
mlops/train.py