Why fraud models lie about accuracy
This is a sample post to show how articles look. Edit it or delete the file.
In the credit card dataset I worked with, only about 1.7% of transactions were fraudulent. A model that labels every transaction as legitimate is therefore right about 98% of the time, and it catches no fraud at all.
That's why accuracy is the wrong headline number for imbalanced problems. Better questions are:
- Recall: of all the real fraud, how much did we catch?
- Precision: of everything we flagged, how much was really fraud?
- PR-AUC: how does that trade-off behave across every threshold?
What changed my results
Oversampling the minority class during training only, never on the test set, moved recall far more than switching between logistic regression and a random forest did.
from imblearn.over_sampling import SMOTE
X_res, y_res = SMOTE(random_state=42).fit_resample(X_train, y_train)
The data you train on matters more than the model you choose.