CREDIT CARD FRAUD DETECTION

82 of 98 frauds caught. 23 customers wrongly flagged.

Ten ways to handle a 577-to-1 class imbalance (class weights, SMOTE, undersampling, SMOTEENN), across logistic regression, random forest, XGBoost and a small neural network, scored on the same 56,962 held-out transactions.

0.8661best AUC-PR
83.7%recall
$9,811net benefit, README costs

SAVED RESULTS Printed by the repo's notebook or README, on the public Kaggle dataset. No model runs in your browser. How this page was built

XGBoost (Balanced)

Compare the ten models

All models were scored on the same held-out 20% (56,962 transactions, 98 of them fraud) at the default 0.5 decision threshold. Pick a metric to rank them, or select a model to load its confusion matrix above.

Precision against recall

Each dot is one model. Oversampling (SMOTE, SMOTEENN, undersampling) pushes recall to about 0.9 on logistic regression but precision collapses to 4 to 6%, which means roughly 1,460 to 2,280 false alarms. Teal dots have AUC-PR of 0.80 or more; the selected model is coral. Hover, focus or tap a dot.

Select a dot to read it.

Full table, from the notebook output. Select a column heading to sort.

SMOTE variants catch more fraud but flag hundreds or thousands of real customers.

Re-price it with your own costs

The README values the best model at a $9,811 net benefit: fraud prevented minus investigation cost. That arithmetic uses only the confusion-matrix counts, so it can be re-run for every model and for different assumptions. The defaults are the notebook's own. The inputs change assumptions, not data.

Notebook default: $122.21, the mean of the 492 fraud rows.
Notebook default: $2.00, charged for every flagged transaction (true and false alarms).
Not in the notebook (default $0). Use it to model customer friction from wrongly blocked cards.
Best net benefit

Net benefit = TP × fraud amount − (TP + FP) × investigation cost − FP × extra false-alarm cost. Missed fraud is not subtracted separately; it is simply fraud that was not prevented, so the ranking is the same either way. At the defaults, XGBoost (Balanced) gives 82 × 122.21 − 105 × 2.00 = $9,811, matching the README. Note that at these defaults XGBoost (Balanced) is not the highest on this dollar view: a $2 investigation is cheap next to a $122 fraud, so high-recall models that flag a few hundred extra transactions edge it out. Raise the investigation or false-alarm cost and the order shifts back toward the precise models.

What drove the predictions

Feature importances saved in the notebook. Note which models they come from: the notebook computes them for Random Forest + SMOTE and XGBoost + SMOTE, not for the headline XGBoost (Balanced) model. The README's "V14 = 56.3%" is the XGBoost + SMOTE figure. V1 to V28 are anonymised PCA components, so they have no readable meaning.

Random Forest + SMOTE, top 10
XGBoost + SMOTE, top 10
Two panels from the notebook: ROC curves for all ten models, all rising steeply near the top-left, and precision-recall curves where models drop sharply past about 0.85 recall.
ROC and precision-recall curves, as saved in the notebook output. ROC curves look nearly identical; the PR curves separate the models, which is why AUC-PR is the primary metric.
Two bar charts from the notebook: top 15 feature importances for Random Forest and XGBoost. V14 is the longest bar in both, about 0.20 for Random Forest and 0.56 for XGBoost.
Original notebook figure for the importance tables above.

How the study works

Every number here was printed by the repo's notebook (credit_card_fraud_detection.ipynb) or its README. No model is run in your browser, and no transaction data is included. The data is the public, anonymised Kaggle "Credit Card Fraud Detection" set (European cardholders, September 2013): 284,807 transactions, 492 of them fraud (0.173%).

  1. Split80/20 stratified split. 227,845 train, 56,962 test, with 394 and 98 frauds. RobustScaler fitted on the training set.
  2. RebalanceOriginal data, SMOTE (227,451 per class), undersampling (394 per class), SMOTEENN, or class weights.
  3. ModelLogistic regression, random forest (100 trees, depth 10), XGBoost (100 trees, depth 6), MLP (100, 50).
  4. JudgeAUC-PR first, then precision, recall, F1, and a dollar view from the confusion matrix.

Read this before quoting the numbers

  • One random split with only 98 fraud cases in the test set. One more or fewer caught fraud moves recall by about one point, so small gaps (for example XGBoost 0.866 vs XGBoost + SMOTE 0.856 AUC-PR) are not established differences. The notebook does not report confidence intervals.
  • The split is random, not time-ordered. The README mentions cross-validation and temporal validation, but neither appears in the notebook's saved outputs, so this page does not report any.
  • Results are at the default 0.5 threshold. The notebook did not save per-transaction scores, only plotted curves, so there is no threshold slider here. A threshold view would need the notebook re-run.
  • The dollar view applies the average fraud amount of the whole dataset to the test set, and the $2 investigation cost is the notebook's illustrative assumption, not data.
  • The notebook's business-impact cell has no saved output; the $9,811 figure comes from the README, and the confusion-matrix counts behind it (82 caught, 23 false alarms) match the saved XGBoost output.