Computer Science & Data / Data Science

Confusion Matrix Metrics Calculator

Confusion Matrix

Metrics

• Accuracy = (TP + TN) / Total

• Precision = TP / (TP + FP)

• Recall = TP / (TP + FN)

• F1 = 2 × (Precision × Recall) / (Precision + Recall)

About This Calculator

Confusion Matrix Metrics Calculator is designed to reduce manual errors and give repeatable outputs when you need quick, reliable answers.

Calculate precision, recall, F1 score, accuracy, specificity, and other classifier metrics from a confusion matrix (TP, FP, FN, TN). Essential for evaluating machine learning models, medical tests, and binary classification systems.

If your workflow expands, pair this calculator with Linear Regression Calculator and Entropy and Information Gain Calculator to cross-check assumptions and build a stronger analysis chain.

Formula

Precision = TP/(TP+FP) | Recall = TP/(TP+FN) | F1 = 2×(Precision×Recall)/(Precision+Recall) | Accuracy = (TP+TN)/(TP+FP+FN+TN) | Specificity = TN/(TN+FP)

Example Calculation

The worked example below demonstrates how the input fields translate into the final output. Use it as a quick validation pass before entering your own numbers.

  • True Positives (TP): 90
  • False Positives (FP): 10
  • False Negatives (FN): 20
  • True Negatives (TN): 180

Explanation of Results

Result Interpretation

Precision = 90/(90+10) = 90%. Recall = 90/(90+20) = 81.8%. F1 = 2×(0.90×0.818)/(0.90+0.818) = 85.7%. Accuracy = (90+180)/300 = 90%. The gap between precision and recall shows the model misses 18% of actual positives — acceptable for some use cases, problematic for medical screening.

FAQ

What is the difference between precision and recall?

Precision answers: 'Of all the things I predicted as positive, how many actually are?' (TP / (TP+FP)). Recall (sensitivity) answers: 'Of all the actual positives, how many did I find?' (TP / (TP+FN)). High precision = few false alarms. High recall = few missed cases. For cancer screening, high recall matters more (don't miss cases). For spam filtering, high precision matters more (don't block real emails).

When should I use F1 score vs accuracy?

Use accuracy only on balanced datasets. When one class is rare (e.g., fraud detection where 99% of transactions are legitimate), a model predicting 'not fraud' always achieves 99% accuracy but zero recall. F1 score balances precision and recall and works better for imbalanced classes. For extreme imbalance, also consider AUC-ROC or the Matthews Correlation Coefficient (MCC).

What is specificity and how is it different from recall?

Specificity (true negative rate) = TN/(TN+FP) — how well the model identifies actual negatives. Recall (sensitivity) = TP/(TP+FN) — how well it identifies actual positives. In medical testing: recall = sensitivity (catching sick patients), specificity = how well healthy patients test negative. A test can be 100% sensitive but 0% specific if it just classifies everyone as positive.

Related Calculators

Continue exploring tools in this topic cluster to improve internal discoverability and reduce orphaned workflows.