D8A Academy © Portfolio Platform
Build · Validate · Get Hired
Free introLeaderboardBlogCheatsheetsCommunity
Sign inGet started
← All cheatsheets
Data Scientist·#014·July 24, 2026·1 min read

The confusion matrix, decoded

Rows, columns, the diagonal, the two error types, and the four formulas that fall out of one small grid. Free one-page PDF.

Get the free PDF

One page, print-ready, free to share. No signup needed.

Download the PDF

Every classification metric you have ever met is arithmetic on four cells. Learn to read the grid once, and precision, recall, F1 and the two error types stop being vocabulary and start being geometry.

The 2x2

predicted positivepredicted negative
actually positiveTP · caught itFN · Type II miss
actually negativeFP · Type I alarmTN · correctly ignored

How to read it

  • Rows are the truth: the actual class.
  • Columns are the model call: the prediction.
  • The diagonal (TP, TN) is where you want the mass.

The four formulas

  • accuracy = (TP + TN) / everything. Fine only when classes balance.
  • precision = TP / (TP + FP). Of my alarms, how many were real?
  • recall = TP / (TP + FN). Of the real ones, how many did I catch?
  • F1 = 2PR / (P + R). One number, imbalance-aware.

Type I vs Type II

  • Type I · FP: the false alarm. Convicted an innocent.
  • Type II · FN: the miss. Let the guilty walk.

The courtroom mnemonic sticks because it makes the tradeoff visceral: which error can your problem afford?

The trap: the fat TN cell

On rare-event problems (fraud, churn, defects), the true-negative cell is enormous. It inflates accuracy while the model misses everything that matters: accuracy 99%, business value zero.

The check: read recall on the rare class first. For the full precision-vs-recall story, see sheet 006.

Frequently asked questions

How do I read a confusion matrix?
Rows are the truth (actual class), columns are the model's call (predicted class). The diagonal cells are correct predictions; everything off the diagonal is an error. You want the mass on the diagonal.
What is the difference between Type I and Type II errors?
Type I is the false positive: a false alarm, convicting an innocent. Type II is the false negative: a miss, letting the guilty walk. Which one is worse depends entirely on the problem, and that choice drives which metric to optimize.
Does a confusion matrix work for more than two classes?
Yes: with N classes it becomes an NxN grid, with the same reading rules. The diagonal is still success, and per-class precision and recall are computed from each row and column.
Which metric from the confusion matrix matters most?
For balanced classes, accuracy is fine. For imbalanced problems, read precision and recall on the rare class, or F1 if you need one number. The fat true-negative cell means accuracy alone can hide a useless model.

Get the free PDF

One page, print-ready, free to share. No signup needed.

Download the PDF

More cheatsheets