HomeToolsConfusion Matrix
All Tools

Confusion Matrix Calculator - Precision, Recall, F1

Confusion Matrix

Calculate classification metrics from your confusion matrix

Predicted +
Predicted -
Actual +
TP
FN
Actual -
FP
TN
Total samples: 200
Accuracy
87.5%
Precision
89.5%
Recall
85.0%
F1 Score
87.2%
Specificity
90.0%

Metrics Comparison

Additional Metrics

Balanced Accuracy87.50%
Matthews Correlation (MCC)0.7509
Negative Predictive Value85.71%
Prevalence50.00%
False Positive Rate10.00%

Formulas

Accuracy(TP + TN) / Total
PrecisionTP / (TP + FP)
RecallTP / (TP + FN)
SpecificityTN / (TN + FP)
F1 Score2 × (P × R) / (P + R)

Interpretation Guide

High Precision, Low Recall:

Model is conservative - few false positives but misses many positives.

Low Precision, High Recall:

Model is aggressive - catches most positives but has many false alarms.

When to use F1:

When you need balance between precision and recall, especially with imbalanced classes.

When to use MCC:

Best single metric for imbalanced datasets. Range: -1 to 1.

How do you calculate precision, recall, and F1 score from a confusion matrix?

A confusion matrix is a table that summarizes a classification model's predictions against actual labels using four counts: True Positives (TP), True Negatives (TN), False Positives (FP), and False Negatives (FN). Precision = TP / (TP + FP) measures what fraction of positive predictions were correct. Recall = TP / (TP + FN) measures what fraction of actual positives were found. F1 Score = 2 × (Precision × Recall) / (Precision + Recall) is the harmonic mean of precision and recall, balancing both metrics. Accuracy = (TP + TN) / (TP + TN + FP + FN) measures overall correctness but can be misleading with imbalanced classes. For example, a spam detector with 95% accuracy might catch only 50% of spam if 95% of emails are not spam. Choose precision when false positives are costly (e.g., medical diagnosis) and recall when false negatives are costly (e.g., fraud detection).

Built with care by Alpiaal