Confusion Matrix Metrics Calculator
Every standard classification metric from the four cells of a confusion matrix — accuracy, precision, recall, specificity, F1, balanced accuracy and Matthews correlation — with a reading of which one to trust for your class balance.
A binary classifier's results fit in four boxes: true positives, false positives, false negatives, true negatives.
How the confusion matrix metrics calculator works
A binary classifier's results fit in four boxes: true positives, false positives, false negatives, true negatives. Accuracy is the share right overall, and it lies when the classes are unbalanced: predicting "no fraud" every time is 99% accurate. Precision asks how many flagged items were real; recall asks how many real items were flagged; F1 balances them.
Matthews correlation uses all four cells and stays honest on any class balance, which is why it is the one to quote when the positives are rare.
Formula: precision = TP/(TP+FP); recall = TP/(TP+FN); F1 = 2PR/(P+R); MCC = (TP·TN − FP·FN) / √((TP+FP)(TP+FN)(TN+FP)(TN+FN))
Worked examples
| Inputs | F1 score | Note |
|---|---|---|
| 20% positives, a decent model | 0.8571 | F1 0.86 |
| Rare positives | 0.5333 | 98.6% accurate, F1 0.53 |
| A perfect classifier | 1 | everything 1 |
FAQFrequently asked questions
What is a confusion matrix?
The four counts of a binary classifier's results: right and wrong, for positives and negatives. Every classification metric is a ratio of some of those four.
Precision or recall?
Precision when a false alarm is costly — a spam filter. Recall when a miss is costly — a cancer screen. F1 when both matter and you need one number.
Why not just use accuracy?
Because with rare positives a model that never predicts positive is highly accurate and useless. The baseline row shows what accuracy you get for free.
What is Matthews correlation?
The correlation between predicted and true labels, from −1 to 1, using all four cells. It is the most honest single number for imbalanced data.
What is balanced accuracy?
The average of recall and specificity — accuracy as if the classes were equally common. It is what accuracy would be on a balanced test set.
Where these figures come from
- Vaswani et al. (2017) — Attention Is All You Need — the transformer architecture the memory arithmetic follows
- Kaplan et al. (2020) — Scaling Laws for Neural Language Models — the compute relationship used for training estimates
- Hoffmann et al. (2022) — Training Compute-Optimal Large Language Models — the tokens-per-parameter guidance ("Chinchilla")
- IEEE 754 — Standard for Floating-Point Arithmetic — the numeric formats behind bytes per parameter
- AI Safety Institute — the UK government AI body
Last checked: September 2026. The relationships here are architectural, not vendor-specific: bytes per parameter follow the numeric format, KV-cache size follows the transformer definition, and token-per-word ratios come from published tokeniser behaviour.