esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

Machine Learning Foundations / Advanced / 03.05

Recall: how many real yeses you catch

Recall asks one question: of all the things that really were yes, how many did the model find? See why misses can be costly, and how to hit a recall target.

14 min readFree

The other half of the story

The last lesson ended with a promise: next, recall, how many of the real yeses you catch. Here it is. Precision looked at the alarms the model raised and asked how many were right. Recall looks the other way. It starts from the things that really were yes, and asks how many the model managed to find.

Picture a lifeguard watching a pool. Precision is about the whistles: when she blows one, is someone really in trouble? Recall is about the swimmers: of everyone who really was in trouble, how many did she notice? A lifeguard who rarely blows her whistle can have perfect precision and still miss a child. That is a recall problem.

You can push recall up with one small trick, and the trick has a price. Most of this lesson is about that price.

Key words

Recall
Of all the real yeses, the share the model found. Also called sensitivity or the true positive rate.
True positive (TP)
A real yes that the model said yes to. A catch.
False negative (FN)
A real yes that the model said no to. A miss.
False positive (FP)
A real no that the model said yes to. A false alarm.
Threshold
The cut-off score. A score at or above it becomes a yes; a score below it becomes a no.
Specificity
Of all the real noes, the share the model correctly called no.

By the end you can work out recall by hand, say when a miss is the worst mistake, and set a recall target.

What recall is

Take every example whose true answer is yes. Count how many of them the model also called yes. Divide the second number by the first. That is recall.

In the four boxes of a confusion matrix, the real yeses are the true positives plus the false negatives. A false negative is still a real yes. The model just missed it. So the formula is:

recall=TPTP+FN\text{recall} = \frac{TP}{TP + FN}

In words: the catches, divided by the catches plus the misses. Google's Machine Learning Crash Course defines it as the proportion of all actual positives that were classified correctly as positives, and notes that false negatives appear in the denominator because they are actual positives that were misclassified as negatives.

A quick example. A screening test is used on 100 people who really have an illness. It flags 83 of them and misses 17. Recall is 83 divided by 83 plus 17, which is 83 out of 100, or 0.83.

A perfect model has no misses at all, so its recall is 1.0. Google's course calls that a 100% detection rate.

Recall has other names. Google's course also calls it the true positive rate, and says another name is probability of detection. In medicine the same number is called sensitivity. Wikipedia says that in information retrieval, sensitivity is called recall. Same number, different habits.

Tip

Recall looks at the real yeses. Precision looks at the model's yeses. Both have TP on top. Only the bottom changes.

The question recall answers

Every metric is a question in disguise. Recall's question is: of the real yeses, how many did we catch? Scikit-learn's user guide puts it the same way: recall is the ability of the classifier to find all the positive samples.

Notice what recall does not ask. It does not care how many false alarms you raised. A model that says yes to everything has a recall of 1.0, and is useless. That is why recall is never read alone.

Recall is not fooled by lots of easy noes either. Google's course notes that on heavily imbalanced data, where one class appears 1% of the time, a model that predicts negative all the time would score 99% on accuracy, despite being useless. Its recall would be 0, which shows the problem straight away.

Quick check

A model looks at 40 emails that really are spam. It marks 30 of them as spam and lets 10 through. What is its recall?

When a miss costs the most

Not all mistakes weigh the same. When a false alarm is cheap and a miss is expensive, recall is the number to watch. Google's course says it directly: for applications like disease prediction, correctly identifying the positive cases is crucial, and a false negative typically has more serious consequences than a false positive.

Here are three places where that holds. They are our own everyday examples, so think of them as ways to practise the idea, not as figures from a study.

  • Disease screening

    A first test is meant to find everyone who might be ill. A false alarm means another check. A miss means someone goes home thinking they are fine. So a screening test is judged first on recall.

  • Fraud checks

    A bank watches card payments. A false alarm means a text asking, "Was this you?" A missed fraud means real money leaves an account. Banks accept many extra texts to catch more fraud.

  • A missing child alert

    A system scans reports to decide which to send to the public. Sending an alert that turns out to be a mistake is a small cost. Failing to send one for a child in danger is a much bigger one. Recall comes first.

Flip it: a system that deletes accounts it thinks are fake should be very sure before it fires, so precision matters more there. The cost of each mistake chooses the metric.

Tip

Before you pick a metric, finish this sentence out loud: "The worse mistake is ___, because ___." If the blank is "missing a real one", reach for recall.

The trade-off with precision

Most models do not give a plain yes or no. They give a score, like 0.72, which you can read as how strongly the model feels it is a yes. To get a yes or a no, you choose a cut-off. Google's course calls it a classification threshold: examples above the threshold go to the positive class, and examples with a lower score go to the negative class.

Now the pull between the two metrics. Lower the threshold, and more examples count as yes. You catch more real yeses, so recall goes up. But you also let in more things that were really no, so false alarms go up and precision falls. Raise the threshold, and the opposite happens.

Google's course says it like this: precision improves as false positives decrease, while recall improves when false negatives decrease, and increasing the threshold tends to decrease the false positives and increase the false negatives. As a result, precision and recall often show an inverse relationship, where improving one of them worsens the other.

Let us watch it happen. We invent 500 people for a screening test: 100 who really have the illness and 400 who do not. Each person gets a made-up score between 0 and 1. People who are ill tend to score higher, but the two groups overlap, as they do in real life. A fixed seed makes the numbers repeatable.

Python
# Made-up screening scores: 100 sick people and 400 healthy people.
import random

random.seed(5)

def clip(x):
    return min(max(x, 0.0), 1.0)

labels = [1] * 100 + [0] * 400
scores = [clip(random.gauss(0.68, 0.18)) if y == 1 else clip(random.gauss(0.32, 0.18)) for y in labels]

print("examples:", len(labels))
print("real yeses:", sum(labels))
print("first five scores:", [round(s, 2) for s in scores[:5]])

Output

examples: 500
real yeses: 100
first five scores: [0.47, 0.47, 0.8, 0.27, 0.65]

The label 1 means really ill. The scores come from a bell-shaped spread (random.gauss) centred near 0.68 for the ill and 0.32 for the healthy. Now we try nine thresholds, from 0.1 to 0.9, count the four boxes at each, and work out recall and precision.

Python
import random

random.seed(5)

def clip(x):
    return min(max(x, 0.0), 1.0)

labels = [1] * 100 + [0] * 400
scores = [clip(random.gauss(0.68, 0.18)) if y == 1 else clip(random.gauss(0.32, 0.18)) for y in labels]

def counts(threshold):
    tp = fp = fn = tn = 0
    for y, s in zip(labels, scores):
        said_yes = s >= threshold
        if said_yes and y == 1:
            tp += 1
        elif said_yes and y == 0:
            fp += 1
        elif not said_yes and y == 1:
            fn += 1
        else:
            tn += 1
    return tp, fp, fn, tn

print("threshold  TP  FP  FN   TN  recall  precision")
for i in range(1, 10):
    t = i / 10
    tp, fp, fn, tn = counts(t)
    recall = tp / (tp + fn)
    precision = tp / (tp + fp) if tp + fp else float("nan")
    print(f"{t:9.1f} {tp:3d} {fp:3d} {fn:3d} {tn:4d}  {recall:6.2f}  {precision:9.2f}")

Output

threshold  TP  FP  FN   TN  recall  precision
      0.1 100 358   0   42    1.00       0.22
      0.2  99 294   1  106    0.99       0.25
      0.3  96 215   4  185    0.96       0.31
      0.4  92 113   8  287    0.92       0.45
      0.5  83  65  17  335    0.83       0.56
      0.6  71  27  29  373    0.71       0.72
      0.7  49   9  51  391    0.49       0.84
      0.8  27   1  73  399    0.27       0.96
      0.9  15   1  85  399    0.15       0.94

Read the table from top to bottom. At a threshold of 0.1, almost everyone is called ill: recall is a perfect 1.00, but precision is only 0.22, so about four out of five alarms are false. At 0.5, recall is 0.83 and precision is 0.56. At 0.9, the model is very picky: recall has dropped to 0.15, so it finds only 15 of the 100 sick people, although nearly all of its alarms are right.

The two columns move in opposite directions. Precision is bumpy at the top: 0.94 at 0.9, a touch below 0.96 at 0.8. With only 16 people flagged, one false alarm moves the number a lot.

Tip

No threshold is right for every job. The table is a menu: pick the row whose trade-off you can live with.

Specificity: recall for the other class

Recall is about the real yeses. What about the real noes? There is a twin metric for them: specificity.

Specificity asks: of the people who really are healthy, how many did the model correctly call healthy? Wikipedia calls it the true negative rate, and in medicine says test sensitivity is the ability to correctly identify those with the disease, while specificity is the ability to correctly identify those without it.

specificity=TNTN+FP\text{specificity} = \frac{TN}{TN + FP}

In words: the correct noes, divided by the correct noes plus the false alarms. Look at the shape. It is exactly recall's formula, with the roles of yes and no swapped. That is why people call specificity the recall of the negative class.

Wikipedia's table also shows that specificity equals one minus the false positive rate. So a high specificity means few false alarms among the real noes. Wikipedia adds that ROC analysis explores this trade-off as one between recall and the false positive rate. A later lesson takes that up.

From our table, at a threshold of 0.5 there are 335 true negatives and 65 false positives, so specificity is 335 out of 400, about 0.84. Lower the threshold and specificity falls too.

Quick check

You lower a model's threshold from 0.6 to 0.3. What usually happens?

A recall target in practice

Real teams rarely say "get the best recall you can." They say: "We must catch at least 95% of the real cases." That is a recall target. The job is to find the threshold that reaches it, and see what it costs.

Because lowering the threshold raises recall, the recipe is short. Try thresholds, and keep the highest one that still meets the target. Highest, because lower adds false alarms for no gain.

  1. 1

    Set the target

    Agree on the recall you need, for example 0.95, before you look at any numbers.

  2. 2

    Try many thresholds

    Go from 0.01 up to 0.99 in small steps and work out recall at each.

  3. 3

    Keep the highest that passes

    Among the thresholds that reach the target, pick the highest one. It costs the fewest false alarms.

  4. 4

    Read the price

    Now look at precision and specificity at that threshold. Ask whether people can live with them.

Here it is in code, on the same made-up data. We go through every threshold from 0.01 to 0.99, and remember the last one that still has recall at or above 0.95. We also print the same numbers at 0.5 for comparison.

Python
import random

random.seed(5)

def clip(x):
    return min(max(x, 0.0), 1.0)

labels = [1] * 100 + [0] * 400
scores = [clip(random.gauss(0.68, 0.18)) if y == 1 else clip(random.gauss(0.32, 0.18)) for y in labels]

def counts(threshold):
    tp = fp = fn = tn = 0
    for y, s in zip(labels, scores):
        said_yes = s >= threshold
        if said_yes and y == 1:
            tp += 1
        elif said_yes and y == 0:
            fp += 1
        elif not said_yes and y == 1:
            fn += 1
        else:
            tn += 1
    return tp, fp, fn, tn

target = 0.95
best = None
for step in range(1, 100):
    t = step / 100
    tp, fp, fn, tn = counts(t)
    if tp / (tp + fn) >= target:
        best = t  # keep going: we want the HIGHEST threshold that still passes

tp, fp, fn, tn = counts(best)
print("highest threshold with recall >= 0.95:", best)
print("recall:     ", round(tp / (tp + fn), 2))
print("precision:  ", round(tp / (tp + fp), 2))
print("specificity:", round(tn / (tn + fp), 2))
print("missed sick people:", fn, "| false alarms:", fp)

tp, fp, fn, tn = counts(0.5)
print("at 0.5 -> recall", round(tp / (tp + fn), 2), "precision", round(tp / (tp + fp), 2), "specificity", round(tn / (tn + fp), 2))

Output

highest threshold with recall >= 0.95: 0.33
recall:      0.96
precision:   0.34
specificity: 0.53
missed sick people: 4 | false alarms: 188
at 0.5 -> recall 0.83 precision 0.56 specificity 0.84

The answer is a threshold of 0.33. At that point recall is 0.96, so only 4 of the 100 sick people are missed. That is the gain. Now the price: precision is only 0.34, so roughly two out of three alarms are false, and 188 healthy people are flagged. Specificity falls to 0.53.

At 0.5, recall was 0.83, precision 0.56 and specificity 0.84. Moving to 0.33 catches 13 more of the 100 sick people, and the false alarms go up a lot. Whether that is worth it is a question about people: what does a follow-up check cost, and what does a missed case cost?

A first screening test can be built like this: a wide net, then a second, more careful test sorts out the false alarms.

Tip

Always report the price next to the target. "Recall of 0.96" alone sounds great. "Recall of 0.96 with a precision of 0.34" is the honest version.

Recap

Recall is TP divided by TP plus FN: of the real yeses, how many you caught. It is also called sensitivity, the true positive rate, or probability of detection. It matters most when a miss is worse than a false alarm. It pulls against precision, and the threshold is the dial that moves them. Specificity is recall's twin for the real noes. When you need a recall target, pick the highest threshold that reaches it, and state the cost in precision.

Juggling two numbers is awkward, so sometimes you want one score that blends them.

Next: the F1 score, one number for precision and recall together.

Sources

How is this lesson?

Last updated on 16 November 2026

Learn with me

Every lesson is free. I add new ones as I learn. Have a question, or want help with your own work? Book a short call.