Knowing If It WorksLesson 12 of 76

Module 2 · Metrics that mean something

Precision and recall, worked on real numbers

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 2 of 10 in this chapter

This chapter’s goalChoose a metric that matches the decision at hand, set a threshold from a real confusion matrix or a precision-recall curve, say whether a model’s 0.8 means anything about probability, and separate a retrieval failure from a generation failure in a system that does both.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
A content filter over 1,000 posts, 60 of them harmfulFlaggedNot flaggedActually harmful48true positives12false negativesActually fine32false positives908true negativesPrecision 48/80 = 0.60, recall 48/60 = 0.80, accuracy 95.6%. A filter that flags nothing at all scores94.0% accuracy from the bottom-right cell alone.
Precision 48/80 = 0.60, recall 48/60 = 0.80, accuracy 95.6%. A filter that flags nothing at all scores 94.0% accuracy from the bottom-right cell alone.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 7Free · no account needed
Lesson steps

Four cells, and everything comes from them

Any yes/no classifier produces four outcomes on a labelled set. A content filter run over 1,000 posts, of which 60 are harmful:

  • It flagged 80 posts.
  • Of those 80, 48 were harmful. These are true positives.
  • The other 32 flagged posts were fine. False positives.
  • 12 harmful posts went through unflagged. False negatives.
  • 908 fine posts were correctly left alone. True negatives.

That is the confusion matrix. Every metric in this lesson is arithmetic on those four numbers, and you should be able to do all of it on paper.

Precision: when it flags, how often is it right?

Text
precision = TP / (TP + FP) = 48 / 80 = 0.60

Recall: of the things that should have been caught, how many were?

Text
recall = TP / (TP + FN) = 48 / 60 = 0.80

F1: the harmonic mean of the two, used when you want one number:

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Shipping It exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘Precision and recall, worked on real numbers’, in Knowing If It Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/evaluating-ai/the-confusion-matrix (Accessed: 27 November 2026).