Report

Help us improve this tool

Accuracy Calculator

Calculate classification accuracy, error rate, precision, recall, specificity, and F1 score from confusion matrix values (TP, TN, FP, FN).

O M T

Understanding Classification Accuracy and Confusion Matrix Metrics

Classification accuracy is one of the fundamental evaluation metrics in machine learning, statistics, and medical diagnostic testing. It measures the proportion of correctly predicted outcomes relative to the total number of evaluation samples.

Accuracy Formula

Accuracy is derived directly from the confusion matrix values:

$$\text{Accuracy} = \frac{\text{TP} + \text{TN}}{\text{TP} + \text{TN} + \text{FP} + \text{FN}}$$

Where:

  • TP (True Positives): Positive instances correctly identified.
  • TN (True Negatives): Negative instances correctly identified.
  • FP (False Positives): Negative instances incorrectly flagged as positive (Type I error).
  • FN (False Negatives): Positive instances incorrectly flagged as negative (Type II error).

Additional Evaluation Metrics

While accuracy provides a quick high-level summary, it can be misleading on imbalanced datasets. Additional metrics provide a more complete assessment:

  • Precision (Positive Predictive Value): $$\text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}}$$
  • Recall (Sensitivity / True Positive Rate): $$\text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}}$$
  • Specificity (True Negative Rate): $$\text{Specificity} = \frac{\text{TN}}{\text{TN} + \text{FP}}$$
  • F1 Score: Harmonic mean of precision and recall: $$\text{F1} = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}$$
  • Error Rate: $$\text{Error Rate} = \frac{\text{FP} + \text{FN}}{\text{Total}}$$

For further statistical analysis, explore our Probability Calculator and ANOVA Calculator.

Frequently Asked Questions

What is a good classification accuracy score?

A good accuracy score depends on the baseline class distribution. In a balanced binary problem, 50% represents random guessing, so scores above 80% to 90% are typically considered strong. For highly imbalanced data, high accuracy alone can be misleading.

Why is accuracy alone not enough for imbalanced datasets?

If 99% of samples belong to the negative class, a model predicting negative every time achieves 99% accuracy while completely failing to identify any positive samples. In such cases, F1 score, precision, and recall are more informative.

What is the difference between Precision and Recall?

Precision measures how many of the positive predictions were actually correct, whereas Recall measures how many of the actual positive cases were successfully captured by the model.

What is the Matthews Correlation Coefficient (MCC)?

MCC is a balanced metric that returns a value between -1 and +1, taking into account all four categories of the confusion matrix even when classes are unbalanced.