Average precision
Average precision summarizes a ranked score list by weighting the precision at each threshold by the increase in recall since the previous threshold.
Non-interpolated AP = sum((R_n - R_(n-1)) * P_n), with thresholds ordered by increasing recall and initial recall zero. Equal scores enter together at one threshold. With distinct scores, AP averages the precision at each positive's rank. [1]
Trapezoidal PR-AUC uses linear interpolation between curve points and can be optimistic. Achievable interpolation between two operating points is generally non-linear in precision-recall space. [1] [3] [4]
Prevalence is the population no-skill precision reference and the AP of a constant-score predictor evaluated as one tied group. It is not generally the mean AP of a finite, tie-free random ranking. For N > 1 fixed observations, M positives (1 <= M <= N), equal weights and a uniformly random ordering independent of labels, E[AP] = M/N + (N-M)(H_N-1)/(N(N-1)), where H_N = sum(1/k), k=1..N. [1] [5]
With one positive among 100 observations, exact null-model arithmetic gives mean random-ranking AP about 0.051874, versus 0.01 for constant scores. An AP of 0.05 is therefore not five times the finite-ranking null mean. Report N, M, tie handling, weighting and class averaging; exceeding a null mean alone does not establish statistical significance. Small positive counts also make area estimates unstable. [5] [3]
Relations
- related
- Precision, Recall, Class prevalence, Probability calibration, SMOTE, Matthews correlation coefficient
Advantages
- AP rewards placing positives near the top of a ranking, so it can compare score orderings before any operating point has been fixed. [1]
Limitations
- A single AP value hides the operating point, so it does not say how many alerts a chosen threshold would produce. [1]
- Estimates near recall zero have high variance, because whether the top-scored example is positive or negative changes where the curve starts. [3]
Citations
- scikit-learn: average_precision_score; non-interpolated AP, trapezoidal contrast and multi-label averaging options.
- Boyd, Eng and Page. Area Under the Precision-Recall Curve: Point Estimates and Confidence Intervals. ECML PKDD 2013, sections 2 to 4.
- Flach and Kull. Precision-Recall-Gain Curves: PR Analysis Done Right. NeurIPS 2015, section 2.
- Manzhos, Ianevych and Melnyk (2026). Average precision at cutoff k under random rankings: expectation and variance. Theorem 1, k=N.
Further reading
Sources & caveats
- sklearn-ap re-read 2026-10-23 for the non-interpolated sum, the contrast with trapezoidal integration and the macro default for multi-label averaging.
- boyd2013 read 2026-10-23, sections 2 to 4, for the plug-in estimator, PR-space interpolation, variance near recall zero and small-sample bias at prevalence 0.1.
- prg2015 read 2026-10-23, section 2, for the prevalence baseline, non-linear interpolation and unachievable regions of precision-recall space.
- The matthews-correlation-coefficient entry links here because it scores one thresholded confusion matrix, while average precision scores the whole ranking without fixing a threshold.
- A companion analysis on disk failure prediction is listed but not used in prose.
- Corrected 2026-11-22: population precision and constant-score AP are distinct from finite tie-free random-ranking AP. Theorem 1, equation (4), with k=N, supplies the exact fixed-count expectation; DOI 10.15559/26-VMSTA298.
- Exact rational enumeration checks every positive-position subset for 2<=N<=10: 54 count pairs and 2035 label sequences. The worked values are null-model arithmetic, not a fleet measurement or new statistical theorem.