ML portfolio results

Four small machine learning projects. Each runs on a laptop CPU in under three minutes and has a test suite, and each is built around a decision someone would have to make instead of a leaderboard score.

Synthetic data throughout. Every dataset is generated by code in this repository, so the feature engineering, leakage tests and evaluation can be read and rerun. None of these numbers say anything about a real business.

Fraud detection

Card fraud at a 0.17% base rate.

The alert threshold comes from putting a cost on each type of error instead of maximising a score. Adding scale_pos_weight to handle the imbalance made the ranking worse.
Fraud detection results Fraud detection results
Ranking quality and money kept. They're on different scales, so each gets its own panel.
ModelPR-AUCPrecisionRecallNet savings
Rule baseline0.30143.0%38.1%46%
Logistic regression0.50644.6%51.5%53%
LightGBM0.75772.7%66.0%60%
LightGBM + weight0.39754.5%62.9%59%

Demand forecasting

28-day demand for 60 SKUs.

Every lag is derived from the forecast horizon, so lag_1 can't be built at a 28-day horizon. Getting this wrong leaks the future into the features.
Demand forecasting results Demand forecasting results
Error by model across six rolling origins, and error by how many days ahead the forecast is.
ModelWAPEWorst foldValue add vs naive
LightGBM (Tweedie)0.3870.404+36%
Lightgbm L20.3970.421+34%
Moving Average 28D0.4760.511+21%
Last Year0.5800.614+4%
Seasonal naive0.6060.623+0%

Semantic similarity

Duplicate question detection.

The split protocol moves the score more than the model does, and changes which model you'd pick. A random pair split leaks questions between train and test.
Semantic similarity results Semantic similarity results
The same four models under both split protocols. The gap between the two bars in each pair is the effect of the protocol.
Modelrandom pair splitcluster disjoint splitDifference
TF-IDF cosine0.5630.588-0.025
Logistic regression0.6550.679-0.024
LightGBM0.8520.689+0.162
LightGBM + question stats0.8610.664+0.197

Recommender system

Implicit-feedback recommendations.

Implicit ALS written from scratch. If you pick a model on accuracy alone, you get one that recommends the same popular items to everyone.
Recommender system results Recommender system results
Recall against catalogue coverage. A model can win on recall while showing a fraction of the catalogue.
ModelRecall@10nDCGCatalogue coverageNovelty
Random0.0040.002100.0%11.24
Popularity0.0530.0341.7%8.11
Item k-NN0.1250.08935.0%9.42
Implicit ALS0.1140.07556.9%9.64