Skip to content
AI.info

Evaluation

Confusion Matrices and Error Taxonomy

Use confusion matrices to connect predictions, outcomes, prevalence, and error consequences before selecting classification metrics.

By the end you can

Every classification metric begins with four counts

A screening system predicts either “review” or “do not review,” while the reference later records whether the event was truly urgent. Before averaging anything, the evaluation contains four distinct outcomes. Those cells describe different mistakes, different affected cases, and often different remedies. A single scalar can hide which cell changed.

Michigan Medicine tested the Epic Sepsis Model against 38,455 hospitalizations recorded between December 2018 and October 2019. Sepsis occurred in 2,552 of them, about 7%. The external validation, published by Wong and colleagues in JAMA Internal Medicine in 2021, reported “a hospitalization-level area under the receiver operating characteristic curve of 0.63 (95% CI, 0.62-0.64)”. That is the number the model is usually remembered by. It shows none of the four counts underneath it.

The same paper gives the counts. The model “did not identify 1709 patients with sepsis (67%) despite generating alerts for an ESM score of 6 or higher for 6971 of all 38 455 hospitalized patients (18%), thus creating a large burden of alert fatigue”. Put those two sentences into one matrix and the four cells fall out. Of the 6,971 alerts, 843 had sepsis behind them and 6,128 did not, so 12.1% of alerts were true — about one in eight. Of the 2,552 patients who developed sepsis, 843 were identified and 1,709 were not, a sensitivity of 33.0%. The fourth cell is the remaining 29,775 hospitalizations with neither an alert nor sepsis. Two cells moved in opposite directions: a third of cases caught, seven alerts in eight wasted. The 0.63 reports neither.

Figure

One reported AUC, taken apart into the counts underneath it: which alerts were right, which cases were missed, and how far apart the two cells are.

Keep the counts visible long enough to understand the system.

Visual

The binary confusion matrix, filled with real numbers

Rows and columns must be labeled. Conventions differ between libraries and between reports, and an unlabeled matrix can be read in two incompatible ways.

One axis is what the system predicted. The other is what the reference process later recorded. The predicted-positive column holds the true positives (reference positive) and the false positives (reference negative). This is where workload enters, and the column a threshold change moves first. The predicted-negative column holds the false negatives (reference positive) and the true negatives (reference negative). This is where missed cases accumulate. It is also where the fallback policy decides the consequence — what happens to a case the system says nothing about.

The Michigan Medicine evaluation fills all four cells at the alert threshold of an ESM score of 6 or higher: 843 true positives, 6,128 false positives, 1,709 false negatives, 29,775 true negatives. They sum to the 38,455 hospitalizations. Every ratio in the rest of this lesson is built from those four numbers and nothing else.

FigureComparison · 2 columns

Predicted positive

The system triggers the positive action.

  • True positive: reference positive
  • False positive: reference negative
  • Workload enters here
  • Threshold changes this column

Predicted negative

The system withholds the positive action.

  • False negative: reference positive
  • True negative: reference negative
  • Missed cases enter here
  • Fallback policy matters

Example

A worked example where the two error cells disagree

A real four-cell split is more instructive than a hypothetical one, because the cells rarely fail together. ProPublica analysed COMPAS risk scores from Broward County in May 2016. Its contingency tables cover the 7,214 defendants scored in 2013–2014 for whom at least two years of recidivism information was available, with criminal records collected through 1 April 2016. ProPublica summarised one cell of that table: “Our analysis found that black defendants who did not recidivate over a two-year period were nearly twice as likely to be misclassified as higher risk compared to their white counterparts (45 percent vs. 23 percent).” The other error cell ran the other way.

  • Reference and unit: 7,214 Broward County defendants scored in 2013–2014, each followed for two years, with criminal records collected through 1 April 2016. The unit is the defendant, not the arrest.
  • Positive class and threshold: COMPAS returns a three-level risk score, and the analysis treats “higher risk” as the predicted positive. That is a binarisation choice, not a property of the instrument.
  • False positives: 44.85% of Black defendants who did not reoffend were labelled higher risk, against 23.45% of white defendants who did not reoffend.
  • False negatives: 47.72% of white defendants who did reoffend were labelled lower risk, against 27.99% of Black defendants who did reoffend.
  • Reading the cells together: the two error rates split by race in opposite directions on the same 7,214 cases. Any summary that reports one cell, or folds both into a single accuracy, will describe the instrument as even-handed while both errors are unevenly distributed. (The figure 6,172 appears in the same investigation but refers to a different sample — the subset used for the decile-score distribution and the logistic-regression models.)

Comparison

Condition on the reference or on the prediction

Two families of metrics answer different questions. Reference-conditioned metrics — recall or sensitivity, specificity, the false-negative rate, the false-positive rate — ask: among the cases the reference calls positive, or negative, how often does the system respond correctly? Prediction-conditioned metrics — precision or positive predictive value, and negative predictive value — ask: among the cases the system calls positive, or negative, how often is it right? The second family depends strongly on prevalence and speaks directly to review yield. The first does not.

Within the reference-conditioned family alone, the two error rates need not travel together. NIST's Face Recognition Vendor Test Part 3 (NISTIR 8280), published in December 2019, ran 18.27 million images of 8.49 million people through 189 mostly commercial algorithms from 99 developers. Its executive summary reports: “Across demographics, false positives rates often vary by factors of 10 to beyond 100 times.” False negatives behave differently in the same evaluation. They “tend to be more algorithm-specific, and vary often by factors below 3”. One cell varies by two orders of magnitude across groups. The other varies by less than three-fold.

An independent university study found the two cells moving in opposite directions across the same groups. Krishnapriya and colleagues measured face-recognition accuracy on the MORPH dataset in 2019. At a fixed decision threshold, the African-American image cohort has the higher false match rate and the lower false non-match rate. A report that names only one of the two families, or only one of its rates, can show that cohort as better served or worse served at will — without changing a single decision the system made.

FigureComparison · 2 columns

Reference-conditioned

Among actual positives or negatives, how often does the system respond correctly?

  • Recall / sensitivity
  • Specificity
  • False-negative rate
  • False-positive rate

Prediction-conditioned

Among predicted positives or negatives, how often is the system right?

  • Precision / positive predictive value
  • Negative predictive value
  • Depends strongly on prevalence
  • Directly affects review yield

Multiclass matrices reveal confusions between categories

For multiple classes, the diagonal contains correct predictions and off-diagonal cells show which classes are confused. A global accuracy can conceal a systematic failure on one cell, and the identity of that cell is usually what a deployment cares about. Inspect counts, row-normalized recall, column-normalized precision, and support for each class. Rare classes need uncertainty estimates, because a handful of errors can move their rates substantially.

The standard demonstration is Gender Shades, published in 2018 by Joy Buolamwini and Timnit Gebru. Their abstract states: “We evaluate 3 commercial gender classification systems using our dataset and show that darker-skinned females are the most misclassified group (with error rates of up to 34.7%). The maximum error rate for lighter-skinned males is 0.8%.” The dataset is the Pilot Parliaments Benchmark, 1,270 subjects. The paper reports true positive rate, error rate, positive predictive value and false positive rate for each of the four intersectional groups rather than one headline number. The spread runs from 0.8% for lighter-skinned males to 34.7% for darker-skinned females, and no single overall accuracy figure for any of the three classifiers displays it.

The finding held when other people rebuilt the test. Later in 2018, a team from IBM Research and UC Berkeley measured the same subgroup ordering on their own reconstruction of the benchmark, PPB*. The IBM Watson classifier scored 82.5% on dark females against 99.3–99.5% on the other three groups. They argued at the same time that skin type itself is not the cause. The ordering of the cells is robust. The explanation of it is a separate question, and the matrix does not answer it.

The identity of the confused classes often matters more than the total number of mistakes.

Key idea

Predictive values move when prevalence moves

Sensitivity and specificity can remain fixed while precision changes sharply, because the base rate under the evaluation has changed. This is not a modelling subtlety. Agencies publish the table.

ECDC's October 2021 guidance on rapid antigen detection tests for COVID-19 holds one hypothetical test at sensitivity 0.80 and specificity 0.98 and varies only the prevalence. At 50 infections per 100,000, the positive predictive value is 0.020: two positives in a hundred are real. At 5,000 per 100,000, the same test at the same operating point has a positive predictive value of 0.678. The report states the rule outright: “In a low prevalence setting (e.g. of <5%), RADTs will generally have a high NPV but a low PPV, with variable levels depending on the inherent performance characteristics of the tests (specificity and sensitivity) (Table 1).” Nothing about the test moved. The population did, and the predictive value went from 0.020 to 0.678.

Field data behaves the same way. CDC's Prince-Guerra and colleagues evaluated the Abbott BinaxNOW rapid antigen test at two community testing sites in Pima County, Arizona, on 3,419 paired swabs collected 3–17 November 2020. Among asymptomatic persons it measured sensitivity of 35.8% and specificity of 99.8%. Those two reference-conditioned numbers are portable across sites in a way the resulting yield is not. Transporting a predictive value to a new population requires either a prevalence assumption stated out loud or a fresh evaluation.

Precision is a property of the model, threshold, and evaluated population together.

Analogy

A warehouse with four bins, emptied one case at a time

Every shipment lands in one of four bins: correctly stopped, wrongly stopped, wrongly passed, or correctly passed. Ratios summarize the bins. But the operational consequences still occur shipment by shipment, and they accumulate across rounds in a way no single-round ratio displays.

Screening mammography is the measured case. A cohort study followed 169,456 US women from their first screening mammogram at ages 40–59, and Hubbard and colleagues published the result in Annals of Internal Medicine in 2011: “When screening began at age 40 years, the cumulative probability of a woman receiving at least 1 false-positive recall after 10 years was 61.3% (CI, 59.4% to 63.1%) with annual and 41.6% (CI, 40.6% to 42.5%) with biennial screening.” A per-round false-positive rate that looks small delivers a false-positive recall to the majority of annually screened women within ten years. The US Preventive Services Task Force's 2024 recommendation puts the modelled burden at 1,376 false-positive results per 1,000 women screened biennially from ages 40 to 74. That is more than one per woman over the programme.

Every metric in the rest of this lesson is some redistribution of the four bins. Knowing which counts a metric puts above the line, which it puts below, and how many rounds those counts are drawn from, is most of knowing what it means.

Ratios are views of the bins, not substitutes for them.

Case

The coefficient that reads all four bins

Some summaries look at the whole matrix. Most look at part of it. The Matthews correlation coefficient “produces a high score only if the prediction obtained good results in all of the four confusion matrix categories”, Chicco and Jurman wrote in BMC Genomics in 2020. Accuracy and F1 score, they found, “can dangerously show overoptimistic inflated results, especially on imbalanced datasets”. One metric reads all four bins. The other two read some of them. That is why the Epic Sepsis Model can report an alert on 18% of hospitalizations while missing 67% of sepsis cases, and why the choice of summary decides which of those two facts survives into the slide.

Steps

Read a confusion matrix in the right order

Reading it reliably means going through the cases before the ratios: verify definitions, inspect raw counts, normalize deliberately, attach consequences, compare slices.

Step 1 — name the positive class, reference process, unit and threshold — is not paperwork. A 2016 reanalysis in Federal Probation took the same Broward County COMPAS data and changed only the binning of the three-level risk score. For Black defendants, binning low against moderate-plus-high gives a false positive rate of 0.42 and a false negative rate of 0.28. Binning low-plus-moderate against high gives 0.14 and 0.62 on the identical defendants. Same people, same instrument, same two-year window, and a false positive rate of either 0.42 or 0.14 depending on where the cut is drawn. Flores, Bechtel and Lowenkamp drew the conclusion: “Regardless, what should be taken away from these tables is the fact that when recommended practices are followed for calculating performance indicators of predictive instruments, a somewhat different pattern of results and conclusions is drawn.” A matrix without its threshold stated is not a result.

Step 2 — check support, missing outcomes and impossible cells — extends to distrusting the reference itself. An audit of the test sets of ten widely used benchmarks, presented at NeurIPS in 2021, put a number on the problem. Northcutt and colleagues write: “we estimate an average of at least 3.3% errors across the 10 datasets, where for example label errors comprise at least 6% of the ImageNet validation set.” Vasudevan and colleagues at Google reached a compatible conclusion a year later: on expert multi-label review, nearly half of the remaining “mistakes” made by top ImageNet models were not mistakes at all. Where the reference is wrong at a few percent, a share of every off-diagonal cell is the label failing rather than the model. From the counts alone, the two are indistinguishable.

Steps 3 to 5 follow from those two. Choose row, column or total normalization for the question actually being asked. Map each error cell to workload, delay, harm or cost: 6,128 false alerts and 1,709 missed sepsis cases are not the same kind of loss. Then repeat the whole matrix for time, subgroup, site and severity. The Broward tables and the Pilot Parliaments groups both show that the aggregate cell is an average over cells that disagree.

FigureProcess · 5 steps
  1. 1. Verify definitions

    Name the positive class, reference process, unit, and threshold.

  2. 2. Inspect raw counts

    Check support, missing outcomes, and impossible cells.

  3. 3. Normalize deliberately

    Choose row, column, or total normalization for the question.

  4. 4. Attach consequences

    Map each error cell to workload, delay, harm, or cost.

  5. 5. Compare slices

    Repeat the matrix for time, subgroup, site, and severity levels.

Key takeaways