# Intersection over union (IoU)

> Canonical: https://skillalmanac.com/glossary/intersection-over-union | Last verified: 2026-11-25 | Index status: index-eligible

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.

## 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](/glossary/computer-vision). A detector predicts a box, a person has drawn the correct [ground truth](/glossary/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](/glossary/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](/glossary/supervised-learning).

## Worked examples in this catalogue

### [data-analysis-eda](https://skillalmanac.com/skills/skill-almanac/data-analysis-eda)

Status: illustrative example from the item's own documentation, not executed for this page.

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.

### [split-leakage-check](https://skillalmanac.com/skills/skill-almanac/split-leakage-check)

Status: illustrative example from the item's own documentation, not executed for this page.

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.

### [huggingface-datasets](https://skillalmanac.com/skills/huggingface/huggingface-datasets)

Status: illustrative example from the item's own documentation, not executed for this page.

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.

## Related terms

- [Computer vision](https://skillalmanac.com/glossary/computer-vision.md)
- [Convolutional neural network (CNN)](https://skillalmanac.com/glossary/convolutional-neural-network.md)
- [Ground truth](https://skillalmanac.com/glossary/ground-truth.md)
- [Supervised learning](https://skillalmanac.com/glossary/supervised-learning.md)
- [Machine learning (ML)](https://skillalmanac.com/glossary/machine-learning.md)
- [Classification](https://skillalmanac.com/glossary/classification.md)

## Sources

- [Metrics and scoring: quantifying the quality of predictions (Jaccard similarity coefficient score)](https://scikit-learn.org/stable/modules/model_evaluation.html), scikit-learn (accessed 2026-11-24)
- [torchvision.ops.box_iou](https://docs.pytorch.org/vision/stable/generated/torchvision.ops.box_iou.html), PyTorch (accessed 2026-11-24)
- [YOLO performance metrics](https://docs.ultralytics.com/guides/yolo-performance-metrics/), Ultralytics (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
