Sub topic 6
Recall: how many real positives were found
This chapter assumes you know the four outcomes (TP, FP, FN, TN) and that scikit-learn puts actual labels on the rows and predicted labels on the columns. Both are covered in earlier chapters.
What recall measures
Recall answers one question: of all the cases that are truly positive, how many did the model find? It is also called sensitivity or the true positive rate.
$$\text{recall} = \frac{TP}{TP + FN}$$
The denominator is every actual positive. In a scikit-learn matrix, that is the sum of the bottom row (the row for actual class 1). Recall ignores the negative row entirely, so false positives never change it.
Worked example
Take ten cases, four of which are truly positive.
from sklearn.metrics import confusion_matrix, recall_score
y_true = [1, 0, 1, 1, 0, 0, 1, 0, 0, 0]
y_pred = [1, 0, 0, 1, 0, 1, 1, 1, 0, 0]
cm = confusion_matrix(y_true, y_pred, labels=[0, 1])
print(cm)
# [[4 2]
# [1 3]]
tn, fp, fn, tp = cm.ravel()
print(tp / (tp + fn)) # 0.75
print(recall_score(y_true, y_pred)) # 0.75The bottom row is [1 3]. One positive was missed (FN = 1) and three were found (TP = 3). Recall is 3 / (3 + 1) = 0.75. The two false positives in the top row do not appear in this calculation.
When recall is the metric to watch
Recall matters most when a miss costs more than a false alarm. Typical cases are:
- Disease screening, where a missed patient goes untreated.
- Fraud detection, where a missed fraud is a direct loss.
- Safety monitoring, where a missed fault can cause damage.
In these settings a false alarm usually triggers a cheap follow-up check. A low recall means the model quietly lets real cases through.
Common errors
- Dividing by the wrong total. Dividing TP by all samples gives a number that depends on class balance. Divide only by actual positives.
- Reading the wrong axis. If a tool puts predictions on the rows, then TP / (TP + FN) uses a column sum. Check the axes first.
- Treating high recall as proof of a good model. A model that predicts positive for every case has recall 1.0 and is useless. Read recall together with precision.
- Mixing up recall and specificity. Recall is about the positive class. Specificity, covered later, is the same idea for the negative class.
Recall and the threshold
Recall depends on the decision threshold. Lowering the threshold turns more predictions into positives, which moves counts from FN to TP. Recall rises, but false positives usually rise too. A later chapter shows this on one set of scores.
Exercise
A fraud model is tested on 1,000 transactions. 50 are truly fraudulent. The model flags 60 transactions, and 40 of those are truly fraudulent. What are the FN count and the recall? Does the 20 false positives figure matter for recall?
Show answer
The model found 40 of the 50 frauds, so TP = 40 and FN = 50 - 40 = 10. Recall = 40 / (40 + 10) = 0.8. The 20 false positives (60 flagged minus 40 correct) do not affect recall. They lower precision instead, which is 40 / 60, about 0.667.