{
  "slug": "average-precision",
  "term": "Average precision",
  "aliases": [
    "AP",
    "non-interpolated average precision"
  ],
  "definition": "Average precision summarizes a ranked score list by weighting the precision at each threshold by the increase in recall since the previous threshold.",
  "note": "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. [sklearn-ap]\n\nTrapezoidal 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. [sklearn-ap] [boyd2013] [prg2015]\n\nPrevalence 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. [sklearn-ap] [random-ap]\n\nWith 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. [random-ap] [boyd2013]",
  "limitations": [
    {
      "text": "A single AP value hides the operating point, so it does not say how many alerts a chosen threshold would produce.",
      "citationIds": [
        "sklearn-ap"
      ]
    },
    {
      "text": "Estimates near recall zero have high variance, because whether the top-scored example is positive or negative changes where the curve starts.",
      "citationIds": [
        "boyd2013"
      ]
    }
  ],
  "related": [
    "precision",
    "recall",
    "class-prevalence",
    "probability-calibration",
    "smote",
    "matthews-correlation-coefficient"
  ],
  "citations": [
    {
      "id": "sklearn-ap",
      "title": "scikit-learn: average_precision_score; non-interpolated AP, trapezoidal contrast and multi-label averaging options.",
      "url": "https://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html",
      "accessed": "2026-11-22"
    },
    {
      "id": "hesela-prediction",
      "title": "Hesela: disk failure prediction, metric denominators and a synthetic alert-count example.",
      "url": "https://hesela.com/analyses/ml-disk-failure-prediction/",
      "accessed": "2026-10-12"
    },
    {
      "id": "boyd2013",
      "title": "Boyd, Eng and Page. Area Under the Precision-Recall Curve: Point Estimates and Confidence Intervals. ECML PKDD 2013, sections 2 to 4.",
      "url": "https://pages.cs.wisc.edu/~boyd/aucpr_final.pdf",
      "accessed": "2026-10-23"
    },
    {
      "id": "prg2015",
      "title": "Flach and Kull. Precision-Recall-Gain Curves: PR Analysis Done Right. NeurIPS 2015, section 2.",
      "url": "https://proceedings.neurips.cc/paper_files/paper/2015/file/33e8075e9970de0cfea955afd4644bb2-Paper.pdf",
      "accessed": "2026-10-23"
    },
    {
      "id": "random-ap",
      "title": "Manzhos, Ianevych and Melnyk (2026). Average precision at cutoff k under random rankings: expectation and variance. Theorem 1, k=N.",
      "url": "https://www.vmsta.org/journal/VMSTA/article/353/text",
      "accessed": "2026-11-22"
    }
  ],
  "status": "shipping",
  "advantages": [
    {
      "text": "AP rewards placing positives near the top of a ranking, so it can compare score orderings before any operating point has been fixed.",
      "citationIds": [
        "sklearn-ap"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-22",
  "provenance": [
    "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."
  ]
}
