Data & ComputingMachine LearningA-Level
AQAAPIBAbiturBaccalauréat GénéralBachilleratoCambridgeCAPS

Confusion matrix accuracy Calculator

Accuracy from true/false positives/negatives.

Use the free calculatorCheck the variablesOpen the advanced solver
This is the free calculator preview. Advanced walkthroughs stay in the app.
Result
Ready
Accuracy

Formula first

Overview

Accuracy is the most intuitive performance measure for classification models, representing the ratio of correctly predicted observations to the total number of samples. It combines both true positive and true negative results to provide a broad assessment of how often the classifier is correct across all classes.

Symbols

Variables

TP = True Positives, TN = True Negatives, FP = False Positives, FN = False Negatives, acc = Accuracy

True Positives
True Negatives
False Positives
False Negatives
Accuracy

Apply it well

When To Use

When to use: Accuracy is best utilized when the target classes in the dataset are nearly balanced, meaning there is a similar number of samples for each label. It is appropriate when the costs of false positives and false negatives are roughly equal.

Why it matters: It allows stakeholders to quickly grasp the reliability of a system in general terms, such as an OCR engine or a simple sentiment analyzer. High accuracy indicates a model that performs well across the entire distribution, assuming the data is not skewed.

Avoid these traps

Common Mistakes

  • Ignoring class imbalance.
  • Using TP only.

One free problem

Practice Problem

An email spam filter processed 100 messages. It correctly identified 45 as spam and 50 as legitimate. However, it mistakenly marked 2 legitimate emails as spam and failed to catch 3 spam messages. Calculate the accuracy of the filter.

True Positives45
True Negatives50
False Positives2
False Negatives3

Solve for:

Hint: Accuracy is the sum of correct predictions (TP and TN) divided by the total number of samples.

The full worked solution stays in the interactive walkthrough.

References

Sources

  1. Wikipedia: Confusion matrix
  2. An Introduction to Statistical Learning (James, Witten, Hastie, Tibshirani)
  3. Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow by Aurélien Géron
  4. Confusion matrix (Wikipedia article)
  5. Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction (2nd ed.).
  6. Géron, A. (2019). Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow (2nd ed.). O'Reilly Media.
  7. A-Level Data & Computing — Machine Learning