Productive Toolbox

Precision Recall Calculator

Calculate precision, recall, F1 score, accuracy, and specificity from confusion matrix values. Free online machine learning evaluation metrics calculator.

📊

Precision Recall Calculator

Enter your confusion matrix values (TP, FP, FN, TN) to instantly calculate precision, recall, F1 score, accuracy, specificity, and more. We do not collect or store what you enter.

Confusion Matrix

Correctly predicted positive

Missed positive (Type II)

Wrong positive (Type I)

Correctly predicted negative

Total samples1,000

Ctrl+Enter to recalculate

Confusion Matrix

90
TP
9.0%
15
FN
1.5%
10
FP
1.0%
885
TN
88.5%
← Predicted Pos | Predicted Neg →

Example Scenarios

Key Metrics

90.00%
Precision
85.71%
Recall
87.80%
F1 Score
Accuracy97.50%
Specificity98.88%
Precision
90.00%
Of all predicted positives, how many were correct?
Recall
85.71%
Of all actual positives, how many were detected?
F1 Score
87.80%
Harmonic mean of precision and recall.
Accuracy
97.50%
Fraction of all predictions that were correct.
Specificity
98.88%
Of all actual negatives, how many were correctly identified?
NPV
98.33%
Negative Predictive Value — accuracy of negative predictions.
FPR
1.12%
False Positive Rate (1 − Specificity).
FNR
14.29%
False Negative Rate (1 − Recall).
MCC
0.8644
Matthews Correlation Coefficient (−1 to +1).

Metrics Overview

Precision90.00%
Recall85.71%
F1 Score87.80%
Accuracy97.50%
Specificity98.88%

How the Precision Recall Calculator Works

This tool computes the core classification evaluation metrics used in machine learning and AI: precision, recall, F1 score, accuracy, and specificity — directly from the four values of a binary confusion matrix (TP, FP, FN, TN). We do not collect or store what you enter.

Enter your confusion matrix values and every metric updates in real time. Toggle the formula panel to see the step-by-step calculation for each metric.

The Confusion Matrix

Predicted PositivePredicted Negative
Actual PositiveTP
True Positive
FN
False Negative
Actual NegativeFP
False Positive
TN
True Negative
  • TP (True Positive): Model correctly predicted Positive
  • FP (False Positive): Model predicted Positive, but actual was Negative (Type I error)
  • FN (False Negative): Model predicted Negative, but actual was Positive (Type II error)
  • TN (True Negative): Model correctly predicted Negative

All Formulas

Precision    = TP ÷ (TP + FP)
Recall       = TP ÷ (TP + FN)        [also called Sensitivity]
F1 Score     = 2 × (Precision × Recall) ÷ (Precision + Recall)
Accuracy     = (TP + TN) ÷ (TP + FP + FN + TN)
Specificity  = TN ÷ (TN + FP)        [also called True Negative Rate]
NPV          = TN ÷ (TN + FN)        [Negative Predictive Value]
FPR          = FP ÷ (FP + TN)        [False Positive Rate = 1 - Specificity]
FNR          = FN ÷ (FN + TP)        [False Negative Rate = 1 - Recall]
MCC          = (TP×TN − FP×FN) ÷ √((TP+FP)(TP+FN)(TN+FP)(TN+FN))

Metric Reference Guide

MetricAnswersBest used when
PrecisionOf all positive predictions, how many were correct?False positives are costly (e.g. spam filter)
RecallOf all actual positives, how many were found?False negatives are costly (e.g. cancer screening)
F1 ScoreBalanced trade-off between precision and recallImbalanced datasets where both FP and FN matter
AccuracyOf all predictions, how many were correct?Balanced datasets with equal class distribution
SpecificityOf all actual negatives, how many were correctly identified?Minimising false alarms
MCCOverall quality of binary classifier, range -1 to +1Imbalanced datasets — more informative than accuracy

Precision vs Recall Trade-off

Precision and recall are inversely related in most classifiers. Increasing the decision threshold raises precision (fewer false positives) but lowers recall (more false negatives). The optimal balance depends on your application:

  • Medical diagnosis: maximise recall — missing a disease is far worse than a false alarm.
  • Spam detection: maximise precision — blocking legitimate email is more disruptive than missing spam.
  • Search ranking: precision@k matters more than overall recall for top results.
  • Fraud detection: recall is critical — missing fraud is expensive; false alerts are manageable.

How to Use the Calculator

  1. Enter the confusion matrix: Type the counts of true positives (TP), false positives (FP), false negatives (FN) and true negatives (TN) from your model's test results, or load a preset example.
  2. Read the metrics: Precision, recall, F1 score, accuracy, specificity, NPV, false positive and false negative rates and MCC update as you type.
  3. Check the working: Open the formula panel to see each metric calculated step by step from your numbers.
  4. Export or save: Export the results as text, CSV or JSON, or save them to the history in this browser to compare models.

Frequently Asked Questions

What is the difference between precision and recall?

Precision = TP ÷ (TP + FP): of everything the model flagged as positive, the share that really was. Recall = TP ÷ (TP + FN): of all the real positives, the share the model found. A cautious model has high precision and low recall; an eager one the reverse.

How is the F1 score calculated?

F1 = 2 × precision × recall ÷ (precision + recall), the harmonic mean of the two, or equivalently 2TP ÷ (2TP + FP + FN). It is high only when both are high. Example: TP 80, FP 20, FN 10 gives precision 0.80, recall 0.889 and F1 0.842.

When should I use F1 instead of accuracy?

When the classes are imbalanced. If 95% of emails are not spam, a model that never flags anything scores 95% accuracy yet catches no spam; its recall and F1 are 0. F1 ignores true negatives, so a large majority class cannot inflate it.

What is MCC (Matthews correlation coefficient)?

MCC = (TP×TN − FP×FN) ÷ √((TP+FP)(TP+FN)(TN+FP)(TN+FN)). It runs from −1 (always wrong) through 0 (no better than chance) to +1 (perfect) and uses all four cells, so it stays informative on imbalanced data.

Should I optimise for precision or recall?

It depends on which mistake costs more. Favour recall when missing a positive is costly, as in disease screening or fraud detection. Favour precision when false alarms are costly, as in spam filtering or automated account bans. Changing the decision threshold trades one for the other.

What are false positives and false negatives?

A false positive (type I error) is a negative case predicted as positive, such as a genuine email sent to spam. A false negative (type II error) is a positive case the model missed, such as a fraudulent payment that was approved.

Does it work for multi-class classification?

It works on one binary confusion matrix. For several classes, count TP, FP, FN and TN for each class against all the others (one-vs-rest), then average the metrics: macro-averaging treats every class equally, micro-averaging weights by the number of samples.