AI GLOSSARY · AI CONCEPTS
Intersection over union (IoU)
Definition
Intersection over union (IoU) is a score from 0 to 1 for how much two regions overlap: the area they share divided by the area they cover together. In object detection it compares a predicted box with a ground-truth box.
Also called: IoU, iou metric, iou object detection, Jaccard index, IoU score.
In plain language
Intersection over union answers one question: how well does a guess overlap the right answer? Picture a photo with a dog in it. A person has drawn a box around the dog, and a model has drawn its own box. IoU measures how much of the two boxes overlap, as a share of everything the two boxes cover. A score near 1 means the boxes almost match, and a score near 0 means they barely touch. The limit is that it only measures overlap: it says nothing about whether the model named the object correctly. In thresholded detection evaluation, teams choose a cut-off for counting a hit; it changes detection decisions and aggregate metrics. Raw IoU for two fixed regions does not depend on that cut-off.
Technical definition
IoU is the size of the intersection of two sets divided by the size of their union, which scikit-learn gives as the Jaccard similarity coefficient, J(y, y-hat) = |y intersect y-hat| / |y union y-hat|. PyTorch's torchvision documents box_iou as the intersection-over-union, also called the Jaccard index, between two sets of boxes, returned as a matrix with one value per pair, using corner coordinates (x1, y1, x2, y2) by default. In object detection, Ultralytics describes IoU as quantifying the overlap between a predicted and a ground truth bounding box, and thresholds on IoU decide whether a detection counts as correct in metrics such as mAP50.
Worked examples in this catalogue
Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.
Skill by Skill Almanac · Illustrative, not executed
data-analysis-eda 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- A fixed exploratory-analysis procedure and CSV profiler that keeps findings descriptive, evidenced and caveated.
- Why it exercises the concept
- The catalogue has no object-detection skill, so this is a contrast case. It shows the habit IoU needs: look at your labelled data and state caveats before trusting a metric.
Skill by Skill Almanac · Illustrative, not executed
split-leakage-check 53/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- A check of train, validation and test files for duplicates, shared groups, time and label leakage, printed as JSON.
- Why it exercises the concept
- The catalogue has no training skills. It is the check to run first, before you trust any detection score.
Skill by Hugging Face · Illustrative, not executed
huggingface-datasets 25/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- Reads Hugging Face datasets through the Dataset Viewer API: metadata, rows, search and filters.
- Why it exercises the concept
- Detection datasets carry ground-truth boxes. This skill lets you look at a dataset's rows, though it does not compute IoU.
How it shows up when you use agents
IoU is a classic machine-learning metric, not an agent feature. You meet it when you evaluate a model that finds objects in images, the work of computer vision. A detector predicts a box, a person has drawn the correct ground truth box, and IoU scores how closely they agree. A coding agent such as Claude Code, Codex or Cursor can write the evaluation script for you, and this is where mistakes creep in.
What breaks when it is misunderstood:
- Box formats differ. The torchvision function defaults to corner coordinates (x1, y1, x2, y2) and also accepts other formats. Feeding it boxes in the wrong format gives plausible but wrong scores.
- A threshold has to be chosen. Ultralytics explains that a detection counts as correct in mAP50 when its IoU with a same-class object is at least 0.50, while mAP50-95 averages over several thresholds. Two reports quoting different thresholds are not comparable.
- IoU ignores the label. A box that overlaps well but names the wrong class is still wrong.
Next action: when an agent writes evaluation code, ask it to state the box format and the IoU threshold in a comment, and run a small hand-checked case first. The catalogue has no training or evaluation skills for detection, so the examples below are adjacent checks on data quality. If you are building a convolutional neural network detector, keep your test images separate from training images.
Common confusions
- IoU versus accuracy. Accuracy counts correct labels. IoU measures overlap between regions, and says nothing about the class.
- IoU versus the Jaccard index. They are the same calculation. The torchvision documentation calls IoU the Jaccard index, and scikit-learn applies it to label sets.
- IoU versus mAP. IoU scores one pair of boxes. mAP, as Ultralytics describes it, uses IoU thresholds to decide which detections count as correct.
- Myth: a high IoU means a good model. One high-overlap box proves little. Raw IoU depends on the two regions, including the ground-truth box. Acceptance thresholds affect detection decisions and aggregate metrics, not that raw overlap value. See supervised learning.
Related terms
Terms that mention Intersection over union (IoU)
3 terms mention this one
More in AI concepts
Sources
- Metrics and scoring: quantifying the quality of predictions (Jaccard similarity coefficient score), scikit-learn (accessed 2026-11-24)
- torchvision.ops.box_iou, PyTorch (accessed 2026-11-24)
- YOLO performance metrics, Ultralytics (accessed 2026-11-24)
Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-25. Wikipedia is never the only source.
Review record
Last verified
Drafted by Claude (original draft); OpenAI Codex (bounded factual repairs); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-25. Last verified .
Change log (5)
- : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled.
- : First version.
- : Verifier pass: applied reviewer corrections to unsupported or misattributed claims.
- : Bounded source repairs: Separated raw region-overlap value from acceptance thresholds and aggregate detection metrics in plain/myth passages. Pending independent re-review.
- : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.