Precision and Recall for Detection
Count true positives, false positives, and false negatives; calculate precision and recall; interpret their practical trade-offs.
Precision and Recall for Detection explained visually
Count true positives, false positives, and false negatives; calculate precision and recall; interpret their practical trade-offs.
What you will learn
Locate objects, represent boxes, filter predictions, evaluate detections, and compare detector designs.
Define precision and recall
An inspection system finds most defective parts, but it also flags many good parts. Another system rarely gives a false alarm, but it misses several defects. Which one is better?
We need more than a single count of correct predictions to answer that. Two useful measurements are precision and recall.
Precision asks: of the detections we kept, how many were correct? Recall asks: of the reference objects we were supposed to find, how many did we detect?
Count matches and calculate both metrics
Let’s use a small example. An image contains ten reference objects. Our detector produces eight predictions. Six match the correct classes and locations. The other two are false alarms.
We have six true positives, two false positives, and four false negatives. A false negative is a reference object that was not successfully detected.
Precision is six divided by eight, which is seventy-five percent. Recall is six divided by ten, which is sixty percent.
These numbers describe different things. The detector was correct on three quarters of its predictions, but it found only sixty percent of the reference objects.
Apply matching rules and threshold changes
For object detection, we must decide what counts as a match. That normally includes the class label and an overlap threshold. We also match predictions to reference objects so that duplicate boxes do not all count as separate successes.
Changing the confidence threshold changes which predictions remain. Raising it often removes weaker false alarms, which can improve precision. But it can also remove correct detections and reduce recall. The exact outcome must be measured on your data.
Interpret the cost of each mistake
Think back to our inspection system. If missing a defect is costly, recall deserves close attention. If every false alarm requires an expensive manual review, precision also matters.
Neither number tells the whole story alone. We need the task, the evaluation rules, and representative examples to interpret them.
Next, we’ll see how average precision summarizes performance across many score thresholds.
Quick check: test your understanding
With 6 true positives and 2 false positives, what is precision?
6 / (6 + 2) = 0.75, or 75%.
With 6 true positives and 4 false negatives, what is recall?
6 / (6 + 4) = 0.60, or 60%.
Can duplicate boxes all count as correct matches to one reference object?
No. Matching rules prevent multiple predictions from claiming the same reference object.
Accessible referenceLesson 68 transcript312 words · Matches the published narration and captionsOpen transcript
An inspection system finds most defective parts, but it also flags many good parts. Another system rarely gives a false alarm, but it misses several defects. Which one is better?
We need more than a single count of correct predictions to answer that. Two useful measurements are precision and recall.
Precision asks: of the detections we kept, how many were correct? Recall asks: of the reference objects we were supposed to find, how many did we detect?
Let’s use a small example. An image contains ten reference objects. Our detector produces eight predictions. Six match the correct classes and locations. The other two are false alarms.
We have six true positives, two false positives, and four false negatives. A false negative is a reference object that was not successfully detected.
Precision is six divided by eight, which is seventy-five percent. Recall is six divided by ten, which is sixty percent.
These numbers describe different things. The detector was correct on three quarters of its predictions, but it found only sixty percent of the reference objects.
For object detection, we must decide what counts as a match. That normally includes the class label and an overlap threshold. We also match predictions to reference objects so that duplicate boxes do not all count as separate successes.
Changing the confidence threshold changes which predictions remain. Raising it often removes weaker false alarms, which can improve precision. But it can also remove correct detections and reduce recall. The exact outcome must be measured on your data.
Think back to our inspection system. If missing a defect is costly, recall deserves close attention. If every false alarm requires an expensive manual review, precision also matters.
Neither number tells the whole story alone. We need the task, the evaluation rules, and representative examples to interpret them.
Next, we’ll see how average precision summarizes performance across many score thresholds.