Confusion Matrix
Variant: Standard
Made-up data, for demonstration only
Variants
4 types · click one to see it in the frame above- Difference from standard
- The recommended type; use it as a starting point
- Use when
- See the error types: TP, FP, TN and FN
Confusion Matrix is a table that compares what a model predicted with the true values. This example is a model that predicts which of 1,000 customers will default on payment (made-up data). Rows are the true values, columns are the predictions, and each cell is a count of items.
How to read a Confusion Matrix
- The diagonal is correct predictions. The cells on the diagonal are the items predicted correctly. Here the model is right for 812 + 84 = 896 customers.
- Off the diagonal are the misses. A false positive is a false alarm: 41 customers did not default but were predicted to. A false negative is a miss: 63 customers did default but were predicted not to.
- accuracy = (TP+TN)/total. Here 896 of 1,000 is 89.6%.
- precision = TP/(TP+FP). The model predicted 125 defaults (84+41), and 84 of them really defaulted, which is 67%.
- recall = TP/(TP+FN). In reality 147 customers defaulted (84+63), and the model caught 84, which is 57%.
- A caution. There are 853 customers who did not default. Predicting "no default" for everyone would score an accuracy of 85.3%, so this model is only about 4 percentage points better.
When to use it
- You evaluate a classification model with a single decision threshold. It shows each kind of error separately, so you can see where the system confuses the two classes.
- Each kind of error has a different cost. For example, a false alarm turns away a good customer, while a miss leads to bad debt.
- You compare before and after tuning the model.
When not to use it
- You want to see results at every threshold. Use a ROC Curve.
- You want to judge from a single number. Accuracy can mislead when the data is imbalanced.
- There are dozens of classes. The table gets too big. Use percent per row and highlight the cells that are often wrong.
- Readers do not know the terms TP, FP, FN and TN. Write them in plain words inside the cells.
Common mistakes
1. Reporting only accuracy
Accuracy misleads when the data set is imbalanced. For example, if 95% belong to one group, always predicting that group scores 95%.
2. Swapping rows and columns without saying so
Some matrices put the true values in rows and others put the predictions in rows. Label it clearly. In this example the rows are the true values.
3. Not saying which class is "positive"
State what the positive class is. In this example "default" is positive.
4. Using counts alone when the classes are unequal
Try the "Percent per row" variant to see the rate for each class.
5. Not highlighting the costly cells
Try the "Highlight the wrong cells" variant, so readers see where the errors are.
Compared with similar charts
| Chart | How it differs | Choose it when |
|---|---|---|
| Confusion Matrix | Results at a single threshold | You look at each kind of error |
| ROC Curve | Results at every threshold | You compare models across thresholds |
| Heatmap | A general colour table | Values across many categories |
| Lift Chart | Results when sorted by score | You choose a target group |
Frequently asked questions
What is a confusion matrix used for?
It checks the results of a classification system by counting the items in each pair of true value and prediction.
What are TP, FP, FN and TN?
A true positive predicted as positive (TP), a true negative predicted as positive (FP), a true positive predicted as negative (FN), and a true negative predicted as negative (TN).
When can I use accuracy?
Use it as an overview when you also consider the size of the groups and the cost of each error. If the groups are imbalanced, also look at precision and recall for the class you care about.
References
- Confusion matrix · Wikipedia · en.wikipedia.orgUsed to confirm: the definition and basics of the confusion matrix
- Receiver operating characteristic · Wikipedia · en.wikipedia.orgUsed to confirm: the definition and basics of the receiver operating characteristic
- confusion_matrix documentation · scikit-learn · scikit-learn.orgUsed to confirm: the meaning of rows and columns, how each cell is counted, and normalising by row
- Model evaluation · scikit-learn · scikit-learn.orgUsed to confirm: the limits of accuracy when the data is imbalanced
Last updated 28 Nov 2026
In the same group
- KPI Card / Big Number
- Gauge / Speedometer
- Progress Bar
- Pareto Chart
- Control Chart
- Run Chart
- Candlestick / OHLC
- Depth / Order Book Chart
- ROC Curve
- Cumulative Gains Chart
- Forest Plot
- Volcano Plot
- Ternary Plot
- Contour / Surface Plot
- 3D Scatter Plot
- Table + Conditional Formatting
- Burndown Chart
- Kaplan–Meier
- Bland–Altman Plot
- Pivot Table / Matrix
- KPI Tree / Driver Tree
- Radial Bar / Progress Ring
- Table with Sparklines
- RAG Scorecard
- Data Table