Mean Average Precision

The number every detection paper reports, built from a precision-recall curve one ranked prediction at a time.

Overview

Deciding what counts as correct

Classification has an obvious notion of right. Spotting doesn't: a box that covers most of an object is partly right, and "partly" has to be resolved before any of it can be counted.

The detail is a threshold on IoU. A guess is a true plus if its IoU with a ground-truth box of the same class is at least the threshold, and if that ground-truth box hasn't already been claimed by a higher-trust guess. Or else it's a false plus. Ground-truth boxes nothing matched are false negatives.

That second rule matters. Without it, ten shared guesses on one object would count as ten successes.

Mean Average Precision

This module needs JavaScript: the images are computed in the page rather than downloaded.

Worth knowing

A prediction counts as correct if its IoU with an unmatched ground-truth box clears a threshold.
Sort every prediction by confidence, walk down the list, and plot precision against recall as you go.
AP is the area under that curve for one class. mAP averages AP across classes.
COCO's headline number averages again over IoU thresholds from 0.50 to 0.95, which is why it is so much lower than the old VOC number.

Mean Average Precision

How a list of boxes with trust scores turns one number. What that number isn't telling you.

Building the curve

Sort all guesses for a class by trust, highest first, and walk down the list. After each one, recompute precision and recall over all seen so far, and plot the point.

The curve in the visualisation is just that walk, one dot per guess. It starts high — the most confident guesses are often right — and sags as the list goes on. Later guesses are less solid while the recall denominator stays fixed.

Mean precision is the area under that curve. It summarises the whole ranking rather than speed at one operating point. This Is what makes it handy: a finder that ranks its correct guesses above its incorrect ones scores well even so of how its confidences happen to be calibrated.

The exact area math has varied. VOC 2007 sampled precision at eleven recall levels. VOC 2010 onward and COCO interpolate more finely. The differences are small and the meanings aren't the same. This Is a reason to compare numbers only within one rule.

From AP to mAP

AP is per class. mAP is the mean of AP over all classes — an unweighted mean, so a class with ten instances counts as much as a class with ten thousand.

That is a deliberate choice and worth knowing. It means mAP is dragged down hard by rare classes the model handles badly. A model can improve its mAP more by fixing one rare class than by getting slightly better at a common one.

Why COCO's numbers look worse

Drag the IoU control. At 0.5 a loosely fitting box counts as a hit. At 0.9 the box has to be nearly exact.

VOC reported mAP at IoU 0.5 alone. COCO's headline metric means mAP over ten thresholds from 0.50 to 0.95 in steps of 0.05, often written mAP@[.5:.95]. It rewards precise localisation rather than rough spotting, and it's much harsher: a finder reporting 0.80 under VOC might report 0.45 under COCO on the same guesses.

So a COCO mAP and a VOC mAP are different readings and must never be checked right. COCO also reports mAP@0.5 alongside, partly so that check remains possible.

COCO breaks the number down further. By object size (small, medium, large) and at fixed spotting counts. Those breakdowns are often more helpful than the headline: "our finder is bad at small objects" is actionable in a way that "our mAP is 0.42" isn't.

What mAP does not tell you

It has no threshold. AP integrates over each trust level, so it says nothing about which threshold to deploy. That is a separate choice.

It skips the cost of errors. A missed pedestrian and a spurious traffic cone count the same.

It means away the failures you care about. A model that is great on 19 classes and useless on the 20th can outscore one that is decent on all of them.

It says nothing about duplicates before NMS. mAP is found on post-processed output, so a finder that fires many shared boxes can look fine if suppression cleans up.

AP is the area, worked

Mean precision is the area under the precision-recall curve, and finding one on a handful of points shows what it rewards. Walk down the trust-sorted guesses, recomputing precision and recall after each:

recallprecision
0.21.00
0.41.00
0.60.67
0.80.50
1.00.40

Summing precision across each recall step gives AP ≈ 0.71. Because it integrates over the whole ranking rather than one operating point, a finder that puts its correct guesses above its wrong ones scores well even so of how its confidences are calibrated — which is just what you want from a summary of a ranking. The catch is that AP has no threshold. It tells you nothing about which trust to deploy, and mAP means it *unweighted* across classes, so a rare class the model handles badly drags the number down as hard as a common one. And COCO's headline means this again over ten IoU thresholds from 0.50 to 0.95, which is why a finder reporting 0.80 under VOC's single 0.50 threshold might report 0.45 under COCO on the same guesses. The numbers are different readings and can't be checked.

What mAP hides is as key as what it reports. It has no threshold, so it says nothing about which trust to deploy. It skips the cost of errors, counting a missed pedestrian and a spurious traffic cone the same. And being an unweighted mean over classes, a model great on nineteen and useless on the twentieth can outscore one that is decent on all. COCO's breakdowns. By object size, at fixed spotting counts — are often more actionable than the headline, because "bad at small objects" tells you what to fix where "mAP 0.42" doesn't. And tuning NMS to lift mAP is a trap: the operating point that raises an integral over all thresholds isn't the one you ship. So It often makes the deployed finder worse.

Where it goes wrong with Mean Average Precision

Checking across datasets or rules. VOC against COCO, or one AP interpolation against another, aren't close.

Reporting mAP alone. Report the per-class breakdown. It's where the info is.

Tuning NMS to raise mAP. Easy to do and often makes the deployed finder worse, because the operating point that raises an integral over all thresholds isn't the one you ship.

Questions people ask about Mean Average Precision

What does mAP measure? How well a detector ranks correct detections above wrong ones, across all classes. It averages the area under each class's precision-recall curve.

What does mAP@0.5 mean? A detection counts as correct if its IoU with a ground-truth box is at least 0.5. mAP@[0.5:0.95], used by COCO, averages across IoU thresholds from 0.5 to 0.95.

How is average precision computed for one class? Sort detections by confidence, walk down the list marking true and false positives, and trace precision against recall. The area under that curve is AP.

Why is mAP preferred over accuracy? Detection has no fixed set of negatives, and accuracy ignores box placement and ranking. mAP rewards both correct localisation and sensible confidence scores.

What is the difference between VOC and COCO mAP? VOC uses a single IoU of 0.5, while COCO averages over ten thresholds and so rewards tighter boxes. The same model gets a lower score under COCO.

Does a high mAP mean the model is ready for production? Not by itself. It hides the operating threshold, per-size performance and rare-class failures, so check the precision-recall curve at the confidence you will deploy at.

From one PR curve to a single number

mAP is the standard score for spotting. It's assembled from parts that each discard a thing. This builds it from raw detections upward -- ranking, matching, precision and recall, interpolation, the class mean -- so that when a number comes back low you know which stage to look at.

example_01.pyNumPy
Output

The next block walks down the ranked list accumulating precision and recall at each step.

example_02.pyNumPy
Output

The next block interpolates the precision-recall curve and computes AP as the area under it, comparing the all-points and 11-point methods.

example_03.pyNumPy
Output

The next block sweeps the IoU threshold from 0.50 to 0.95 the way COCO does, then averages the column to get the headline COCO AP.

example_04.pyNumPy
Output

The next block shows the 'm' in mAP: the unweighted average over classes, which gives rare classes equal weight.

example_05.pyNumPy
Output

Check yourself

0 of 3

Answer without scrolling back up.

  1. Why must a matched ground-truth box be excluded from later matches?

  2. Why is a COCO mAP much lower than a VOC mAP on the same predictions?

  3. What does mAP say about which confidence threshold to deploy?

Cheat sheet

Mean Average Precision

Sort detections by confidence, compute precision and recall at each step, and watch the area under that curve collapse into one mAP number.

COMPUTER VISION · vizlearn.in/computer_vision/mean_average_precision.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.