Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Why is accuracy a poor metric for imbalanced data, and what should you use instead?

If 99% of transactions are legitimate, a model predicting "legitimate" every time achieves 99% accuracy and catches zero fraud. Accuracy measures the majority class and hides total failure on the class you care about.

Better metrics, from the confusion matrix:

  • Precision = TP / (TP + FP). Of everything flagged, how much was right. Matters when false positives are costly — flagging a legitimate customer's card.
  • Recall (sensitivity) = TP / (TP + FN). Of everything that was positive, how much did you catch. Matters when misses are costly — a missed disease diagnosis.
  • F1 — the harmonic mean of the two, when you need a single balanced number.
  • ROC-AUC — ranking quality across all thresholds, but it is optimistic on heavily imbalanced data because the true negative count dominates.
  • PR-AUC — precision-recall AUC, which is the better summary metric for rare positives.

Handling the imbalance itself: class weights in the loss function (usually the first thing to try), resampling with SMOTE or undersampling, threshold tuning on the predicted probability, or collecting more minority examples.

Note: The most important point is that the threshold is a business decision. The model outputs a probability; where you cut it depends on the relative cost of a false positive versus a false negative. Presenting that as a curve for stakeholders to choose from is better than picking 0.5 by default.

All Machine Learning interview questions

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as