My classification model has 95% accuracy but is useless — why?

poze 4 months ago127 gadeen

6

I'm predicting fraudulent transactions. The model reaches 95% accuracy on the test set but catches almost no fraud. What's going on?

Dyagnostik IA

Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.

poze 4 months ago

1 Repons

9
✓
✓ Repons yo aksepte

Classic class imbalance. If 95% of transactions are legitimate, a model that always predicts "not fraud" gets 95% accuracy while catching zero fraud. Accuracy is the wrong metric here.

1. Use the right metrics: precision, recall and F1 for the fraud class, the confusion matrix, and PR-AUC (more informative than ROC-AUC for rare classes).

from sklearn.metrics import classification_report
print(classification_report(y_test, y_pred, digits=3))

2. Handle the imbalance: class_weight='balanced' (or scale_pos_weight in XGBoost/LightGBM), or resampling on the training set only. 3. Tune the decision threshold. The default 0.5 is arbitrary. Pick the threshold from the precision-recall curve based on business cost: how expensive is a missed fraud versus a false alarm that blocks a customer? 4. Use a stratified split, and for fraud a time-based split, so you don't train on the future.

Konekte pou di lòt moun si li te mache.

answered 4 months ago

Sign in and verify your email to post an answer.