Accuracy lies when the rare case is the one that matters

Precision, recall, and why 99% can be a useless model

If one case in a hundred is the one you care about, a model that never finds it is 99% accurate. Precision and recall say what accuracy hides.

Suppose one transaction in a hundred is fraudulent. A model that answers "not fraud" every time is right 99 times out of 100. Its accuracy is 99%, and it has never caught anything.

The four outcomes

Every prediction on a yes/no question lands in one of four boxes: a true positive (said yes, was yes), a false positive (said yes, was no), a false negative (said no, was yes) and a true negative. Accuracy counts the two correct boxes and ignores which kind of mistake you made.

Two questions instead of one

  • Precision: of everything the model flagged, how much was really positive? Low precision means many false alarms.
  • Recall: of everything that was really positive, how much did the model find? Low recall means missed cases.
  • The two pull against each other. Flag more things and recall rises while precision falls.

    Choosing where to stand

    Most models output a score and you pick a threshold. Where it should sit depends on the cost of each mistake. A screening test for a serious illness accepts false alarms to avoid misses. A spam filter that hides real mail accepts a few spam messages to avoid losing something important. There is no universal best threshold, only one that fits the cost.

    One number when you need one

    The F1 score combines precision and recall, and punishes a model that is good at only one. It is a summary, not a decision. Look at the two numbers underneath it.

    Lessons

  • Ask how rare the thing you care about is before trusting accuracy.
  • Report precision and recall, not only accuracy.
  • Set the threshold from the cost of each kind of mistake.
  • Compare against the model that always says "no".
  • Tagged: machine-learning, evaluation, metrics

    Area: AI

    Related notes

    עברית