{
  "slug": "confusion-matrix",
  "term": "Confusion matrix",
  "aliases": [
    "classification confusion matrix"
  ],
  "definition": "A confusion matrix tabulates predicted labels against observed labels for a specified set of classification decisions.",
  "note": "Axis labels matter: scikit-learn places observed classes in rows and predictions in columns, while Fawcett's Figure 1 uses the transposed convention. With rows = observed, columns = predicted and class order [0, 1], the binary matrix is [[TN, FP], [FN, TP]], where 1 is the positive class. [matrix-api] [fawcett]\n\nKeep raw counts alongside normalized values. Row normalization conditions on the observed class, column normalization on the predicted class, and whole-matrix normalization on all included observations. A 2-by-2 array without its class order and axis convention is ambiguous. [matrix-api]\n\nFor drive prediction, specify the failure label, prediction horizon, threshold and observation unit. A matrix of daily decisions is not a count of distinct drives or replacement actions. Unresolved outcomes must not silently become healthy labels; retain the exclusion and follow-up rules. This is an application of the counting definition, not a performance claim. [fawcett]\n\nIn a synthetic 10,000-decision example, [[9801, 99], [10, 90]] yields 90 true alerts, 99 false alerts and 10 missed positives. The negative-class denominator is 9900; the alert denominator is 189. [worked]",
  "related": [
    "specificity",
    "balanced-accuracy",
    "precision",
    "recall",
    "false-positive-rate",
    "prediction-horizon",
    "prediction-cadence"
  ],
  "citations": [
    {
      "id": "matrix-api",
      "title": "scikit-learn: confusion_matrix; axis conventions, label order and normalization.",
      "url": "https://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html",
      "accessed": "2026-11-22"
    },
    {
      "id": "fawcett",
      "title": "Fawcett (2006). An introduction to ROC analysis, section 2 and Figure 1. DOI: 10.1016/j.patrec.2005.10.010.",
      "url": "https://www.math.ucdavis.edu/~saito/data/roc/fawcett-roc.pdf",
      "accessed": "2026-11-22"
    },
    {
      "id": "worked",
      "title": "Hesela: synthetic classification counts, exact fractions and edge-case checks.",
      "url": "https://hesela.dev/research/classification-denominators/results.json",
      "accessed": "2026-11-22"
    }
  ],
  "provenance": [
    "Reviewed 2026-11-22: Fawcett section 2 and Figure 1, plus the confusion_matrix API documentation.",
    "Storage-specific reporting guidance is Hesela's application of the counting definition. Worked counts are synthetic, with exact rational checks."
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-22"
}
