Measure mistakes on unseen scenes

Count false alarms and missed objects, choose a threshold on validation data, and inspect actual model predictions.

Guided walkthrough·Intermediate·4 min read

Inspect threshold tradeoffs

These are three invented predictions on one illustrative image, not output from your trained model. Change the confidence threshold and count accepted errors as well as correct boxes.

An illustrative block and diskA block fills coordinates 40,50 to 110,120. A disk is centered at 220,100 with radius 25. There are two real objects. 2 correct and 1 incorrect predictions pass the threshold.block 0.92disk 0.42block 0.65

TP 2 · FP 1 · FN 0. Precision 67%. Recall 100%.

The false block scores 0.65, above the correct disk at 0.42. A confidence score is not a guarantee that the class and box are right.

Predict recall at a threshold of 0.80 before moving the slider.

Requirements and learning goals

Before you start

  • The trained baseline and dataset from lesson 2
  • The same activated Python environment

You will be able to

  • Explain precision and recall
  • Evaluate class and box correctness together
  • Choose a threshold without using the final test set

Count what the detector gets wrong

A true positive is a prediction with the right class and a box that sufficiently overlaps a real object. A false positive is an unmatched prediction, including a wrong class or an extra duplicate box. A false negative is a labeled object that no accepted prediction matches.

is TP / (TP + FP): how many accepted predictions were correct? is TP / (TP + FN): how many real objects were found? If there are no predictions, precision is undefined rather than perfect. If there are no labeled objects, recall is undefined. Our report uses JSON null for those cases.

The browser picture is an invented worked example, not output from your checkpoint. At threshold 0.25 it accepts two correct boxes and one false alarm. Precision is 2/3 and recall is 2/2. At 0.60 it removes the correct disk but retains the higher-scoring false alarm: both precision and recall become 1/2. Raising a threshold does not guarantee that every metric improves.

Checkpoint 1 of 2

A report at one threshold counts 12 true positives, 3 false positives, and 4 false negatives. What are precision and recall?

Commit to an answer. Every choice explains itself.

Compare actual predictions

Use the same project directory and activated environment as the training lesson:

python workshop.py evaluate --split val --confidence 0.25 --output reports/val-025
python workshop.py evaluate --split val --confidence 0.60 --output reports/val-060

Each output directory contains annotated images and report.json. The report includes the model hash, threshold, image count, totals, and per-image errors. The evaluator greedily matches predictions in descending confidence order to unused labels of the same class. A match requires intersection over union of at least 0.5. Intersection over union is the shared box area divided by the area covered by either box. A real object can match only one prediction.

These are fixed-threshold precision and recall values. They are not the average-precision scores printed by the trainer, which summarize a different calculation across thresholds.

Checkpoint 2 of 2

Two accepted predictions of class disk both overlap the same labeled disk with intersection over union above 0.5. Their confidences are 0.90 and 0.70. How does the evaluator count them?

Commit to an answer. Every choice explains itself.

Try a change and explain it

Predict recall at 0.80 in the browser lab before moving its slider. Then inspect the two actual validation reports. Find an image with a missed object or false box if one exists. If both reports are perfect on this simple dataset, say so and identify a real-world condition the generator does not cover, such as occlusion or clutter. Do not invent a failure or claim general robustness.

Choose a threshold on validation data based on which errors matter for your task. A counting tool may tolerate some extra boxes differently from an alarm. Record the threshold and reason before opening the final test results in the capstone.

Check the expected result

Each actual report covers 20 validation images and 16 labeled objects. Therefore true_positive + false_negative should equal 16. Precision and recall can differ from the illustrative browser example. The browser example at 0.80 has one true positive, no false positives, and one false negative, giving precision 100% and recall 50%.

You are done when you can explain one threshold tradeoff and point to the report that supports your decision.

Troubleshooting

If a report directory already exists, use a new output name to preserve the earlier comparison. If the checkpoint is missing, finish training or pass --model with the correct path. If validation rejects a label, fix the annotation before interpreting metrics. Empty predictions are a valid result; check the threshold, class names, and images instead of treating absence of detections as a tool failure.

Can you do each of these?

  • Explain precision and recall
  • Evaluate class and box correctness together
  • Choose a threshold without using the final test set

0 of 2 checkpoints solved. Try checkpoint 1

Previous: Train a small detector on a supplied dataset
All lessons in this topic
  1. 1. Choose objects, label boxes, and split scenes
  2. 2. Train a small detector on a supplied dataset
  3. 3. Measure mistakes on unseen scenes
  4. 4. Use your own objects and keep an honest final test

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.