Anybody Can AI

Quick Stats

Completed

0

Time Spent

0m

Streak

0

User

User

Machine Learning Foundations

Training and Evaluating Models/Picking the Right Metric

Picking the Right Metric

Accuracy is not enough.

Why accuracy lies

"Accuracy" — the fraction of predictions you got right — feels like the obvious score, and for balanced problems it's fine. But it falls apart the moment your classes are imbalanced. If 99% of emails are legitimate, a lazy model that labels everything "not spam" is 99% accurate and completely useless — it never catches a single spam. High accuracy, zero value. This trap shows up constantly: fraud, disease, defects, churn — the rare cases you care most about are exactly the ones accuracy ignores.

The metrics that tell the truth

For imbalanced or high-stakes problems, look at these instead:

  • Precision — of the items the model flagged, how many were actually right? (Few false alarms.)
  • Recall — of the items it should have flagged, how many did it catch? (Few misses.)
  • F1 — the harmonic mean of the two, a single number when you want balance.
  • Confusion matrix — the raw counts of right and wrong per class; read it and the others become obvious.

Precision vs. recall is a choice

You usually can't max both — pushing one up nudges the other down — so you decide based on which mistake is more expensive:

  • A cancer screening test should favor recall: missing a real case is far worse than a false alarm you can re-test.
  • A spam filter should favor precision: junking one real email annoys the user more than letting an occasional spam through.

Decide this before you train, because it dictates which metric you optimize and where you set the decision threshold.

Accuracy answers "how often am I right?" — but the useful question is usually "what does it cost when I'm wrong?" Pick the metric that matches the mistake you most want to avoid.

Try this: For a prediction in your domain — loan approvals, quality checks, content moderation — write down which is worse: a false positive or a false negative. Your answer tells you whether to chase precision or recall, and that single decision shapes the whole model.