Confusion Matrix Calculator

The confusion matrix is the foundation of classification evaluation: it cross-tabulates predicted vs actual labels. Enter your four counts (true positives, false positives, false negatives, true negatives) and this tool derives accuracy, precision, recall/sensitivity, specificity, F1, balanced accuracy, prevalence, error rate, negative predictive value, and both error rates.

Correctly predicted positives.

Predicted positive but actually negative.

Predicted negative but actually positive.

Correctly predicted negatives.

Result

Enter your values and press Calculate — the result appears here.

Worked examples

A model with 85% accuracy

  • tp = 50
  • fp = 10
  • fn = 5
  • tn = 35

Result: Accuracy 0.85 · Precision 0.8333 · Recall 0.9091 · F1 0.8696

Perfect classifier

  • tp = 40
  • fp = 0
  • fn = 0
  • tn = 60

Result: Accuracy 1.0 · all error rates 0

No actual positives

  • tp = 0
  • fp = 20
  • fn = 0
  • tn = 80

Result: Accuracy 0.8 · Recall and F1 undefined — no actual positives to find

Frequently asked questions

What is a confusion matrix?

A 2×2 table comparing predictions to reality: TP (predicted positive, actually positive), FP (predicted positive, actually negative — a false alarm), FN (predicted negative, actually positive — a miss), TN (predicted negative, actually negative). Every classification metric derives from these four counts.

Which metrics are undefined when?

Precision needs at least one positive prediction (TP + FP > 0); recall/sensitivity needs at least one actual positive (TP + FN > 0); specificity needs at least one actual negative (TN + FP > 0). When a denominator is zero, that metric has no meaningful value and is labeled as undefined.

Why is accuracy alone not enough?

With imbalanced classes, a model that always predicts the majority class can look accurate. On a data set that is 90% negative, always predicting negative gives 90% accuracy but zero recall. Precision, recall, and F1 reveal that failure.

💬 Discuss on BestWordz Community

Join the conversation about Machine Learning, confusion matrix, tp fp fn tn on the BestWordz Community forum.

Visit Forum →
Copied!