Back to library

📊Understand Confusion Matrices, Precision, and Recall

Stop reaching for accuracy by reflex — read a confusion matrix in seconds, compute precision and recall by hand, and pick the right metric for spam, fraud, and cancer-screening problems without second-guessing.

Foundations14 drops~2-week path · 5–8 min/daytechnology

Phase 1Reading the Confusion Matrix

See why one accuracy number hides the real story

4 drops
  1. A 99% accurate cancer detector that catches zero cancers

    6 min

    A 99% accurate cancer detector that catches zero cancers

  2. Every classifier mistake fits in one of four boxes

    6 min

    Every classifier mistake fits in one of four boxes

  3. False positives and false negatives don't cost the same thing

    6 min

    False positives and false negatives don't cost the same thing

  4. Precision asks 'when I said yes, was I right?' Recall asks 'did I catch them all?'

    7 min

    Precision asks 'when I said yes, was I right?' Recall asks 'did I catch them all?'

Phase 2Computing the Metrics by Hand

Compute precision, recall, and F1 on tiny datasets

5 drops
  1. Twenty emails, four minutes, every metric on paper

    7 min

    Twenty emails, four minutes, every metric on paper

  2. F1 is the harmonic mean — it punishes the weaker number

    7 min

    F1 is the harmonic mean — it punishes the weaker number

  3. Move the threshold and watch precision and recall trade places

    7 min

    Move the threshold and watch precision and recall trade places

  4. You can't have perfect precision and perfect recall at the same time

    7 min

    You can't have perfect precision and perfect recall at the same time

  5. When 1% of your data is the class you care about, accuracy is poison

    7 min

    When 1% of your data is the class you care about, accuracy is poison

Phase 3Choosing Metrics in Real Domains

Choose precision or recall by the cost of mistakes

4 drops
  1. The product manager wants 'fewer spam emails' — what do you actually optimize?

    7 min

    The product manager wants 'fewer spam emails' — what do you actually optimize?

  2. The screen you can't afford to miss tells a different story

    7 min

    The screen you can't afford to miss tells a different story

  3. When false alarms have a real customer-facing cost, the math gets cost-weighted

    7 min

    When false alarms have a real customer-facing cost, the math gets cost-weighted

  4. Pick the curve that doesn't lie about the rare class

    7 min

    Pick the curve that doesn't lie about the rare class

Phase 4Picking the Right Metric for Three Real Problems

Pick the right metric for three real problems

1 drop
  1. Defend a metric for spam, fraud, and screening — in writing

    8 min

    Defend a metric for spam, fraud, and screening — in writing

Frequently asked questions

What is the difference between precision and recall?
This is covered in the “Understand Confusion Matrices, Precision, and Recall” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
When should I optimize for precision vs recall?
This is covered in the “Understand Confusion Matrices, Precision, and Recall” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Why is accuracy a bad metric for imbalanced data?
This is covered in the “Understand Confusion Matrices, Precision, and Recall” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
What does the F1 score actually measure?
This is covered in the “Understand Confusion Matrices, Precision, and Recall” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
When should I use a PR curve instead of an ROC curve?
This is covered in the “Understand Confusion Matrices, Precision, and Recall” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.