Last updated: February 24, 2026

Confusion Matrix Calculator

Table of contents

How It Works

A confusion matrix is a table that compares predicted classes with actual outcomes. It shows how many predictions fall into each possible category, including correct results and different types of errors. This way, it provides more insight than a single performance score. 

From this table, four values are extracted. True positives and true negatives represent correct predictions. False positives and false negatives represent different error types. 

The confusion matrix calculator uses these four counts as inputs. Once you enter them, the tool calculates performance indicators. Accuracy provides a general correctness overview. Precision and recall explain the balance between different types of errors. At the same time, rate-based metrics highlight how predictions behave across classes. In other words, the confusion matrix calculator converts basic counts into meaningful metrics about model behavior.

Formula

The confusion matrix calculator uses the following formulas to produce the results:

Accuracy = (TP + TN) ÷ (TP + FP + FN + TN)

Precision = TP ÷ (TP + FP)

Recall = TP ÷ (TP + FN)

F1 Score = 2 × (Precision × Recal) ÷ (Precision + Recall)

True Positive Rate = TP ÷ (TP + FN)

False Negative Rate = FN ÷ (TP + FN)

False Positive Rate = FP ÷ (FP + TN)

True Negative Rate = TN ÷ (FP + TN)

False Discover Rate = FP ÷ (TP + FP)

Matthews Correlation Coefficient (MCC) = (TP × TN – FP × FN) ÷ √((TP + FP) × (TP + FN) × (TN + FP) × (TN + FN))

Where:

  • True Positives (TP) are the cases correctly predicted as positive
  • False Positives (FP) are the cases predicted as positive but actually negative
  • False Negatives (FN) are the cases predicted as negative but actually positive
  • True Negatives (TN) are the cases correctly predicted as negative

Example

Suppose a binary classification model produces the following results:

  • TP = 80
  • FP = 20
  • FN = 10
  • TN = 90

Accuracy → (80 + 90) ÷ (80 + 20 + 10 + 90) = 0.85

This means 85% of all predictions are correct. 

Precision → 80 ÷ (80 + 20) = 0.8

As a result, one out of five positive predictions is incorrect. 

Recall → 80 ÷ (80 + 10) = 0.89

This shows that most positive cases were detected. 

Using precision and recall, the F1 score becomes:

F1 Score → 2 × (0.8 × 0.89) ÷ (0.8 + 0.89) = 0.842

Rate-based metrics provide additional context:

True Positive Rate → 80 ÷ (80 + 10) = 0.889

False Negative Rate → 10 ÷ (80 + 10) = 0.111

False Positive Rate → 20 ÷ (20 + 90) = 0.182

True Negative Rate → 90 ÷ (20 + 90) = 0.818

False Discover Rate → 20 ÷ (80 + 20) = 0.2

Finally, the Matthews correlation coefficient is calculated as:

MCC → (80 × 90 – 20 × 10) ÷ √((80 + 20) × (80 + 10) × (90 + 20) × (90 + 10)) = 0.7

Why the Confusion Matrix Metrics Matter in Practice

Confusion matrix metrics matter because different errors have different consequences. A model can achieve high accuracy, but still produce critical mistakes. That happens when one type of error dominates the results. 

For example, a model with high recall but low precision detects most positive cases, yet it also produces many false alarms. In contrast, high precision with low recall predications are cautious, but many real cases are missed. Because of this trade-off, looking at one metric in isolation isn’t enough. 

Rate-based metrics add another layer of understanding. They show how errors scale relative to each class. This makes comparisons between different models more reliable. Meanwhile, the Matthews correlation coefficient provides a stable summary score. In practice, these metrics support threshold adjustments and more confident evaluation decisions. 

FAQ

  1. What does a confusion matrix show?
    It shows how many times a model predicted each class correctly or incorrectly. Specifically, it counts how often positive cases were predicted as positives, negative cases as negatives, and how often the model made each type of mistake. 
  2. Why shouldn’t I rely only on accuracy?
    Accuracy hides how errors are distributed. A model can score high but still miss important cases or produce misleading positives. That’s why additional metrics are needed to interpret performance correctly. 
  3. When should one focus on recall?
    Recall matters when missing a positive case has serious consequences. In those situations, detecting as many real cases as possible is a priority, even if some false positives appear. 
  4. What does the Matthews correlation coefficient indicate?
    It measures how well predictions correlate with actual outcomes. Unlike accuracy, it is still informative when class sizes are uneven. Because of that, data scientists often use this metric for balanced model comparison. 
  5. Can this tool be reused for different datasets?
    Yes. Any binary classification result that provides true positives, false positives, false negatives, and true negatives can be evaluated using the confusion matrix calculator.  

 

All in all, the confusion matrix calculator helps interpret binary classification results in a direct way. It automates the calculations of the performance metrics. This allows you to focus on analyzing results instead of working through formulas by hand. Input your confusion matrix values into the calculator and review the resulting performance metrics in one place with ease. 

Confusion matrix
True positive
False positive
False negative
True negative
Analysis results
Accuracy
decimals
Precision
decimals
Recall
decimals
F1 score
decimals
True positive rate
decimals
False negative rate
decimals
False positive rate
decimals
True negative rate
decimals
False discovery rate
decimals
Matthews correlation coefficient
decimals