← Back to projects
Credit card fraud detection
284k transactions with 0.17% fraud. Compared models by precision, recall and PR-AUC, tuned the decision threshold and explained predictions with SHAP.
Problem
Only 0.17% of transactions are fraud. A model that says "not fraud" for everything is 99.83% accurate and catches none, so accuracy is useless. The challenge is catching fraud without blocking honest customers' cards.
What I built
- Exploration of the 284,807 records and a comparison of logistic regression, Random Forest and XGBoost.
- Comparison of balancing strategies (class weights, undersampling, oversampling) and hyperparameter search with cross-validation.
- Decision threshold tuning and SHAP explanations of predictions, including the frauds the model missed.
Decisions
- Models compared by precision, recall, F1 and PR-AUC of the fraud class, never by accuracy.
- Selection by PR-AUC rather than recall alone: maximizing recall is easy if you flag everything as fraud.
- Class weights plus threshold tuning, without discarding or synthesizing data.
Results
- Tuned XGBoost (threshold 0.44): catches 83 of 98 frauds with 15 false alarms across 57k test transactions.
- PR-AUC of 0.884, against 0.0017 for a random model.
Screens


