{
  "slug": "class-prevalence",
  "term": "Class prevalence",
  "aliases": [
    "positive-class prevalence",
    "class proportion"
  ],
  "definition": "Class prevalence is the proportion of observations belonging to a specified class in a defined population or evaluation sample.",
  "note": "For a nonempty binary sample, positive prevalence = (TP + FN) / (TP + FP + FN + TN). Predicting every observation positive gives precision equal to that prevalence, which is where a precision-recall curve starts at recall 1. [sklearn-pr-curve] A random classifier has the same precision, so the precision-recall baseline is P / (P + N) and moves with the class ratio. [saito2015] [prg2015]\n\nUnder a fixed decision rule and unchanged class-conditional feature distributions, changing only prevalence preserves population true and false positive rates while precision can change. Finite-sample estimates can still vary. This condition is satisfied by label shift; an arbitrary fleet change need not satisfy it. [lipton-icml18] With 80% recall and 10% FPR, precision is about 89% at a 1:1 ratio but about 44% at 1 positive per 10 negatives.\n\nSampling more failures changes the evaluation prevalence and may change precision, and a balanced test sample does not directly establish deployment alert quality. [saito2015] For storage, specify whether an observation is a drive or a drive-day window, and whether positive means failure within a stated horizon. This proportion is not an annualized failure rate.",
  "limitations": [
    {
      "text": "Prevalence measured on one window or fleet need not hold later, because class distributions can shift over time and between sites.",
      "citationIds": [
        "fawcett2006"
      ]
    },
    {
      "text": "Areas under precision-recall curves from samples with different prevalence are not directly comparable.",
      "citationIds": [
        "saito2015"
      ]
    }
  ],
  "related": [
    "precision",
    "recall",
    "false-positive-rate",
    "average-precision",
    "drive-day",
    "afr",
    "f1-score",
    "temporal-validation",
    "probability-calibration",
    "direct-standardization",
    "label-shift"
  ],
  "citations": [
    {
      "id": "sklearn-pr-curve",
      "title": "scikit-learn: precision_recall_curve; the all-positive endpoint.",
      "url": "https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html",
      "accessed": "2026-10-23"
    },
    {
      "id": "saito2015",
      "title": "Saito and Rehmsmeier. The Precision-Recall Plot Is More Informative than the ROC Plot When Evaluating Binary Classifiers on Imbalanced Datasets. PLOS ONE, 2015.",
      "url": "https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0118432",
      "accessed": "2026-10-23"
    },
    {
      "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": "fawcett2006",
      "title": "Fawcett. An introduction to ROC analysis. Pattern Recognition Letters 27 (2006) 861-874, section 4.2. DOI: 10.1016/j.patrec.2005.10.010.",
      "url": "https://people.inf.elte.hu/kiss/11dwhdm/roc.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": "lipton-icml18",
      "title": "Lipton, Wang and Smola. Detecting and Correcting for Label Shift with Black Box Predictors. ICML 2018, assumptions A.1-A.3 and Lemma 1.",
      "url": "https://proceedings.mlr.press/v80/lipton18a/lipton18a.pdf",
      "accessed": "2026-11-23"
    }
  ],
  "status": "shipping",
  "advantages": [
    {
      "text": "A target prevalence and transferable class-conditional operating rates determine expected precision without retraining.",
      "citationIds": [
        "fawcett2006",
        "lipton-icml18"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-23",
  "provenance": [
    "sklearn-pr-curve re-read 2026-10-23 for the first precision value equal to class balance at recall 1.",
    "saito2015 re-read 2026-10-23 for the P / (P + N) baseline and its effect on the area under the precision-recall curve.",
    "fawcett2006 read 2026-10-23, section 4.2, for column-ratio invariance, the 1:10 skew example and the reported range of class skews.",
    "prg2015 read 2026-10-23, section 2, for the random-classifier precision baseline.",
    "The 89% and 44% values are arithmetic from the stated rates, not reported results.",
    "The direct-standardization entry links here because it adjusts rates for population composition, and prevalence is the composition term that changes precision between an evaluation sample and a target population.",
    "A companion analysis on disk failure prediction is listed but not used in prose.",
    "2026-11-23: qualified rate transfer using Lipton et al. assumption A.1 and Lemma 1; preserved the earlier 89%/44% arithmetic and all stable IDs."
  ]
}
