Accuracy

Machine Learning
Introduced by
Historical statistical foundations
Year
20th century
Type
Evaluation metric
Family
Classification Metric

What does it do?

Accuracy is the proportion of correct predictions among all predictions made by a classification model.

It is the simplest overall performance measure for classifiers and treats every prediction equally, regardless of class. Its value is easy to read, but it does not show which kinds of error the model makes.

The intuition behind the method

Accuracy answers one question: how many predictions were correct out of all predictions? It is the count of correct predictions divided by the total number of predictions. Every sample counts equally, and the metric does not weight classes or error types differently. This makes it easy to understand, but it can mislead when classes are imbalanced. A model that always predicts the majority class can reach high accuracy while being useless for the minority class.

History

The origin of accuracy as a metric is not established in the references available for this page. Its use as the proportion of correct predictions is standard in classification practice, but the page does not attribute it to a specific originator or date.

When to use it

Choose accuracy when the classes are roughly balanced and the question is how often the classifier is right overall, for example on balanced image classification tasks or standard benchmark datasets. It is a reasonable first screen when all classes matter about equally. Do not rely on it alone when the minority class is rare and important, as in fraud detection or disease diagnosis, because a majority-class predictor can score well. It is also a poor choice when false positives and false negatives have very different costs, since accuracy does not distinguish between them.

Limitations and considerations

  • Because the formula depends only on the total of correct predictions, a classifier that always predicts the majority class can score highly on imbalanced data.
  • TP and TN enter the numerator, and FP and FN enter the denominator, with equal weight, so accuracy cannot tell a false alarm from a missed case.
  • With several classes of unequal importance, one overall figure can hide poor performance on a small class, so per-class results are needed.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Requires no hyperparameters and only the counts of correct and incorrect predictions, so it can be computed directly from a confusion matrix.
  • Every test sample contributes equally, so the value reads directly as the fraction of correctly labelled cases in the test set.
  • When models are evaluated on the same balanced test set, their accuracy values can be compared directly.

Applications

  • Balanced image classification tasks, such as recognizing handwritten digits (MNIST) or identifying common objects.
  • Standard machine learning benchmark evaluations where class proportions are known to be roughly equal.
  • Initial model screening to identify poor performers before deeper analysis with specialized metrics.
  • Multi-class classification problems where all classes are equally important and well-represented.

How it works

How it works

1

Count the test samples and the correct predictions. In a binary setting, correct predictions are true positives (TP) and true negatives (TN), and incorrect predictions are false positives (FP) and false negatives (FN). The denominator is therefore TP + TN + FP + FN, so it must include the errors as well as the correct predictions. For K classes, the numerator is the number of samples whose predicted label equals the true label, and the denominator is the total number of samples.

Formula
\text{Samples: } N,\quad \text{correct predictions: } TP + TN \ (\text{binary}),\quad \sum_{k=1}^{K} C_{kk} \ (\text{K classes})
2

Binary case: accuracy = (TP + TN) / (TP + TN + FP + FN). Multi-class case with K classes: accuracy = (number of samples with predicted label equal to true label) / (total number of samples), which is the trace of the confusion matrix divided by the sum of all its entries. The binary formula is the special case K = 2. The result lies between 0 and 1 and is often reported as a percentage.

Formula
\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN} \quad\text{(binary)}, \qquad \text{Accuracy} = \frac{\sum_{k=1}^{K} C_{kk}}{\sum_{i=1}^{K}\sum_{j=1}^{K} C_{ij}} \quad\text{(K classes)}
3

A higher value means a larger share of predictions was correct overall. Because accuracy does not separate the types of error, check the confusion matrix and per-class metrics when classes are imbalanced or when false positives and false negatives carry different costs. Worked example: in a binary test set whose confusion matrix has TN = 17, FN = 1, FP = 1 and TP = 1, accuracy = (17 + 1) / (17 + 1 + 1 + 1). The positive-class recall is TP / (TP + FN) = 1 / (1 + 1), so half of the positive cases are missed even though the overall accuracy is high.

Common pitfalls

  • Using accuracy as the sole metric for an imbalanced problem without comparing it against the majority-class rate, which can give false confidence in a poor model.
  • Comparing accuracy values across test sets with different class proportions; the same classifier can score differently when the class mix changes.
  • Choosing the decision threshold to maximise accuracy without considering the cost of each type of error.

Frequently asked questions

Why is accuracy misleading for imbalanced datasets?

In imbalanced datasets, a classifier can achieve high accuracy by simply predicting the majority class for all samples. For example, in a dataset where 99% of cases are negative and 1% are positive, a model that predicts 'negative' for everything achieves 99% accuracy but is useless for identifying the important minority class.

How does accuracy differ from precision and recall?

Accuracy measures overall correctness across all classes. Precision measures the proportion of positive predictions that were correct, while recall measures the proportion of actual positive cases that were identified. Accuracy does not separate these kinds of error, so precision and recall address different aspects of classification performance.

What threshold should I use for accuracy to consider a model good?

There is no universal threshold. An acceptable value depends on the application, the class balance, and the cost of each type of error. Compare accuracy with a baseline, such as always predicting the majority class, and with other models evaluated on the same test data before judging it.

Related methods

Sources

  1. Fawcett, T. (2006). An introduction to ROC analysis. Pattern Recognition Letters, 27(8), 861-874.

    Open DOI reference
  2. Powers, D. M. (2011). Evaluation: From Precision, Recall and F-Measure to ROC, Informedness, Markedness and Correlation. Journal of Machine Learning Technologies, 2(1), 37-63.

    Open publication reference