Evaluate predictions and bounding boxes
Measure classification results and compare predicted object regions with ground truth.
- Calculate intersection over union and interpret a vision metric.
A vision model should be evaluated on data separate from training. For classification, a confusion matrix counts correct and incorrect labels; precision and recall describe different error tradeoffs. For object detection, intersection over union (IoU) measures overlap between a predicted bounding box and a ground-truth box: intersection area divided by union area. Metrics summarize behavior, but do not replace checking examples and data coverage.
1intersection = 40
2union = 100
3iou = intersection / union
4print(round(iou, 2))0.4
IoU ranges from 0 (no overlap) to 1 (identical boxes). Detection systems often use an IoU threshold to decide whether a predicted box matches an object. Dataset imbalance, lighting, camera angle, and underrepresented groups can affect real-world performance.
Key takeaways
Calculate intersection over union and interpret a vision metric.
Small arrays make vision ideas concrete.
Check model performance across varied real-world examples.
Lesson quiz
4 questions · pass with 3 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: apply computer vision with Python
Use small pixel arrays to explore vision concepts, run your code against sample images, and connect each result to the larger computer vision idea.
Calculate box overlap
Read intersection area and union area as two numbers. Print IoU to two decimal places. The union area is positive.
- Partial overlap
- Perfect overlap
Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…