Imbalanced Classification & Failure Analysis

Deployed

Credit Card Fraud Detection

End-to-end fraud detection MVP on 284,807 transactions with XGBoost, SHAP explainability, and failure mode analysis.

Key Performance Metrics

0.79
XGBOOST PR-AUCPrecision 0.80, recall 0.76 on 56,746 test rows
0.82
FLAML PR-AUCAutoML benchmark, precision 0.96, recall 0.77
0.03
FALSE ALARM RATE18 false positives in 56,746 tests

Executive abstract

Detecting credit card fraud requires navigating extreme class imbalance (only 473 fraud cases across 283,726 deduplicated transactions). This project develops a production-grade XGBoost pipeline, demonstrates why class weighting outperforms SMOTE, and performs structured failure analysis using SHAP values.

Empirical exhibit

Exhibit 3.1: Model evaluation and benchmark

PR-AUC & Precision-Recall Benchmark on 56,746 Test Transactions

Benchmark comparison table across Logistic Regression, Main XGBoost with class weighting, and FLAML tuned XGBoost on 56,746 transactions with 95 frauds. The main XGBoost model achieves 0.79 PR-AUC with 18 false positives and 23 false negatives.
Model ArchitectureDecision CutoffPrecisionRecallF1 ScorePR-AUC
Logistic Regression (Baseline)0.500.850.590.700.69
XGBoost (Main Model with Scale Weight)0.500.800.760.780.79
FLAML-Tuned XGBoost (AutoML Ceiling)0.2222*0.960.770.850.82
*Note from repository: FLAML threshold was selected by maximizing F1 on the test set; in practice at threshold 0.5 it yields precision 0.99, recall 0.75.
SHAP-based failure analysis taxonomy (41 total errors across 56,746 samples):
Type 1: Borderline cases[Addressable via Threshold Slider]

Transactions hovering directly around the 0.5 decision boundary (probabilities between 0.40 and 0.60). These can be controlled interactively in the Streamlit application to favor recall over precision depending on fraud risk tolerance.

Type 2: Confident misses[Feature Blindness / Anonymized PCA Overlap]

Transactions where anonymized PCA components (V1-V28) completely overlap with legitimate spending distributions. Cannot be fixed by threshold tuning alone; requires raw behavioral transaction metadata.

Class Imbalance & Weight Selection over SMOTE

Instead of generating synthetic fraud points with SMOTE (which often invents unrealistic transaction feature combinations in high-dimensional space), the model uses scale_pos_weight. The optimal weight (24) was selected via 5-fold stratified cross-validation on the training set only, achieving a 0.848 CV PR-AUC.

SHAP-Driven Failure Mode Analysis

Analyzing the 18 false alarms and 23 missed frauds revealed two distinct failure types: borderline cases near the 0.5 decision boundary that are easily tuned via threshold sliders, and confident misses where anonymized PCA features overlap entirely with legitimate transactions.

Interactive Streamlit Comparison Application

The deployed Streamlit app allows users to inspect caught frauds, false alarms, and missed transactions side by side between the main XGBoost model and a FLAML-tuned benchmark, with real-time SHAP waterfall attribution plots.

What I would do differently

I would incorporate a custom monetary cost matrix into the objective function so that the decision threshold directly minimizes expected financial loss rather than maximizing generic F1 score.

Technical implementation stack

PythonXGBoostLogistic RegressionSHAPStreamlitFLAMLScikit-learn
Notification message