Measure mistakes on unseen scenes
Count false alarms and missed objects, choose a threshold on validation data, and inspect actual model predictions.
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.
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.
Opening the Python editor…
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.
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-060Each 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.
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.
Before you move on
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