Confusion matrix accuracy Calculator
Accuracy from true/false positives/negatives.
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
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.
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
- Wikipedia: Confusion matrix
- An Introduction to Statistical Learning (James, Witten, Hastie, Tibshirani)
- Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow by Aurélien Géron
- Confusion matrix (Wikipedia article)
- Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction (2nd ed.).
- Géron, A. (2019). Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow (2nd ed.). O'Reilly Media.
- A-Level Data & Computing — Machine Learning