Confusion Matrix & Evaluation Metrics Calculator

Read the Theory Guide →

Enter TPTP, FNFN, FPFP, and TNTN counts into the confusion matrix and see Accuracy, Precision, Recall, and F1 Score update as you type. The calculation breakdown shows how each metric is obtained from your values.

What You Can Explore

  • Enter whole-number counts for TPTP, FNFN, FPFP, and TNTN in the four cells of the confusion matrix.
  • Edit any count and watch all four metric scorecards update immediately.
  • Compare Accuracy, Precision, Recall, and F1 Score for the same set of predictions.
  • Read the Calculation Breakdown to see each formula applied directly to your entered values.
Core Mechanics
▼
  • Decoding the Acronyms: Read them backward! The second letter (P or N) is what your model *guessed*. The first letter (T or F) tells you if that guess was *True (Right)* or *False (Wrong)*.
  • The Accuracy Trap: High accuracy is dangerously misleading if your classes are imbalanced. A lazy model can reach 99% accuracy by just guessing the majority class every single time, while missing every single rare case you actually care about.
  • Precision (Quality Control): Of everything your model *claimed* was Positive, how many actually were? It measures how much you can trust your model when it screams "Positive!"—too many false alarms destroy this score.
  • Recall (The Dragnet): Of all the *actual* Positives hidden in the real data, how many did you catch? Recall is about your model's ability to hunt down every single target; missing real ones destroys this score.
Initializing Workspace...

Understanding Your Result

Every metric comes from the four counts you entered, not from a fixed example. The scorecards show the resulting percentages, while the Calculation Breakdown shows which counts each metric uses and how your values produce the result.

  • Accuracy uses all four counts, while Precision and Recall ignore TNTN. With the other values fixed, changing TNTN therefore affects Accuracy without changing Precision or Recall.
  • Precision depends on TPTP and FPFP, while Recall depends on TPTP and FNFN. Compare these metrics with the corresponding error count to see what kind of mistake is affecting each one.
  • F1 Score combines Precision and Recall using their harmonic mean. It stays between the two values and is pulled closer to the lower score, so a large gap between Precision and Recall keeps F1 from being high.
  • If you clear a cell, the metrics cannot be calculated until all four counts contain valid values again. Edit the numbers when you want to experiment while keeping the results visible.

Try These Experiments

Inflate the True Negatives

Setup: Start with the preloaded values TP=20TP=20, FN=5FN=5, FP=10FP=10, and TN=65TN=65. Note the Accuracy of 85% and the other three metric values.

Action: Change TNTN from 65 to 965 while leaving the other three counts unchanged.

What to Observe: Accuracy rises from 85% to 98.5%, while Precision, Recall, and F1 Score remain unchanged. Compare the Calculation Breakdown to see why only Accuracy responds to the change.

Takeaway: A large number of true negatives can make Accuracy appear very high because TNTN contributes directly to its numerator and denominator. Precision, Recall, and F1 are unaffected by TNTN, so looking at Accuracy alone can hide how the model performs on positive cases.

Raise the False Positives

Setup: Reset to the preloaded values and note that Precision is 66.7% while Recall is 80%. Keep both values in view before making the change.

Action: Change FPFP from 10 to 40 while leaving TPTP, FNFN, and TNTN unchanged.

What to Observe: Precision falls from 66.7% to 33.3%, while Recall remains at 80%. Accuracy and F1 Score also decrease because the additional false positives affect their calculations.

Takeaway: False positives directly reduce Precision because they increase its denominator without increasing TPTP. Recall does not use FPFP, so it remains unchanged when only false positives are added.

Swap False Positives and False Negatives

Setup: Reset to the preloaded values, where FP=10FP=10 and FN=5FN=5. Note the four metric values before changing the error counts.

Action: Set FPFP to 5 and FNFN to 10, effectively swapping the two error counts while keeping TPTP and TNTN unchanged.

What to Observe: Precision and Recall exchange their values, becoming 80% and 66.7%. Accuracy remains 85%, and F1 Score remains 72.7%.

Takeaway: Precision and Recall respond differently to false positives and false negatives, while Accuracy and F1 treat the two error counts symmetrically when the other values remain fixed. This lets you see why Precision and Recall provide different information about the same predictions.