Skip to content
AI & Machine Learning Rich #confusion-matrix#precision#recall

Confusion Matrix Anatomy

TP, FP, FN, TN. Every classifier metric falls out of these four counts.

A free, animated confusion matrix anatomy you can read here or embed on any website, from Scrollchart.

Confusion Matrix Anatomy

Confusion Matrix AnatomyEvery classifier metric falls out of TP, FP, FN, TN. Counts: 400 examples, 200 positive, 200 negative.PredictedActualPositiveNegativePositiveNegativeTPTrue Positive17085.0% of actual pos.FNFalse Negative3015.0% of actual pos.FPFalse Positive2010.0% of actual neg.TNTrue Negative18090.0% of actual neg.n=200n=200pred=190pred=210Derived metricsPrecisionTP / (TP+FP)89.5%Recall (TPR)TP / (TP+FN)85.0%F1 Score2PR / (P+R)87.2%Accuracy(TP+TN) / all87.5%SpecificityTN / (TN+FP)90.0%FP = Type I errorfalse alarm, cry wolfFN = Type II errormissed detectionThreshold shifts redistribute counts; precision and recall trade off via FP and FN

A 2x2 matrix with predicted vs actual classes. The four cells light up with derived metrics: precision, recall, F1, accuracy, specificity. As the threshold moves, counts redistribute live. Multi-class extension shown with a 5x5 matrix where the diagonal dominates for a strong model.

Good for

  • Classifier metric tutorials explaining how precision, recall, F1, and specificity all derive from four counts
  • Healthcare-AI articles where the cost asymmetry between FP and FN drives threshold selection
  • Class-imbalance content showing why accuracy alone is an unreliable metric on skewed datasets

Source & accuracy

This confusion matrix anatomy is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

The four outcomes: TP, FP, FN, TN

A confusion matrix for binary classification is a 2 by 2 table counting four outcomes. True Positives (TP): the model predicted positive and the actual label is positive (correct). True Negatives (TN): predicted negative, actual negative (correct). False Positives (FP): predicted positive, actual negative (incorrect; a false alarm). False Negatives (FN): predicted negative, actual positive (incorrect; a miss).

The matrix reveals class imbalance effects. A dataset with 99% negatives can achieve 99% accuracy by always predicting negative, yet the model is useless. The confusion matrix exposes this: it would show zero TP and zero FP, revealing that the positive class was never recognized.

Deriving metrics from the matrix

Common metrics derive from these four cells. Precision = TP / (TP + FP) answers 'of predictions of positive, how many were correct?' Recall (or sensitivity) = TP / (TP + FN) answers 'of actual positives, how many did we find?' The F1-score is the harmonic mean of precision and recall, balancing both.

Different domains prioritize different metrics. Medical diagnosis prioritizes recall (miss no true cases, even if some false alarms). Spam filtering prioritizes precision (avoid false positives, even if some spam slips through). The confusion matrix lets you compute all these metrics and choose the one matching your cost structure. Accuracy alone is insufficient; always examine the full matrix.

Embed this diagram

Add this animated confusion matrix anatomy to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated confusion matrix anatomy for any website.
Who uses it
AI/ML blogs, CS educators, Medical educators.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="confusion-matrix" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "Confusion Matrix Anatomy" for my website?
Scrollchart provides "Confusion Matrix Anatomy" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a confusion matrix anatomy in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.