What accuracy measures
Accuracy is the most common single-number summary of how well a classifier performs. It answers a simple question: out of every prediction the model made, what fraction did it get right? In a binary classification problem, each prediction falls into one of four cells of a confusion matrix — true positive (TP), true negative (TN), false positive (FP), and false negative (FN). Accuracy adds up the two "correct" cells and divides by the total.
The formula
Accuracy = (TP + TN) / (TP + TN + FP + FN)
Equivalently, accuracy is simply the number of correct predictions divided by the total number of predictions. It is a pure ratio between 0 and 1, and is usually reported as a percentage by multiplying by 100. The error rate is its complement: error rate = 1 − accuracy = (FP + FN) / (TP + TN + FP + FN).
What the four cells mean
- True positive (TP): the actual label is positive and the model correctly predicted positive.
- True negative (TN): the actual label is negative and the model correctly predicted negative.
- False positive (FP): the actual label is negative but the model wrongly predicted positive (a "false alarm", or Type I error).
- False negative (FN): the actual label is positive but the model wrongly predicted negative (a "miss", or Type II error).
A worked example
Suppose a spam filter is evaluated on 200 emails: TP = 85, TN = 90, FP = 10, FN = 15. Correct predictions = 85 + 90 = 175, and the total = 200. Accuracy = 175 / 200 = 0.875 = 87.5%, so the error rate is 12.5%. The filter labelled 25 emails incorrectly (10 legitimate emails flagged as spam, and 15 spam emails let through).
Why accuracy alone can mislead
Accuracy weights every prediction equally, which is a problem when the classes are imbalanced. If 99% of transactions are legitimate and 1% are fraud, a model that predicts "legitimate" for everything reaches 99% accuracy while catching zero fraud. Whenever one class dominates, always report accuracy alongside precision (TP / (TP + FP)), recall (TP / (TP + FN)), and F1 score, or use balanced accuracy — the average of recall on each class.