Accuracy Explained: Definition, Formula, and Use Cases

Accuracy is a classification evaluation metric that measures the proportion of correct predictions. This article explains the accuracy formula using a confusion matrix and describes how to combine it with precision, recall, and F1 score when samples are imbalanced.

What Is Accuracy?

Accuracy is a commonly used evaluation metric in machine learning classification tasks. It is used to measure the proportion of correct predictions made by a model among all samples. More intuitively, it answers this question: among all the predictions made by the model, how many results are correct?

In Chinese contexts, Accuracy is also often referred to as the “correctness rate.” However, in model evaluation, accuracy is not a vague judgment of whether something is “right or wrong”; rather, it is a metric with a clearly defined statistical scope. To understand it, you need to consider the task objective, class distribution, and whether metrics such as precision and recall should also be used.

Accuracy can be compared to grading a test: there are 100 questions in total, and 82 are answered correctly, so the accuracy is 82%. This analogy helps build intuition, but in real classification tasks, you also need to further examine which classes were predicted correctly, which classes were predicted incorrectly, and whether different errors are equally important.

Key point: Accuracy is suitable for quickly understanding the overall proportion of correct predictions made by a model, but it does not necessarily explain the model’s performance on every class of samples.

Accuracy Formula and the Four Types of Results in a Confusion Matrix

In binary classification tasks, accuracy is often calculated using a confusion matrix. A confusion matrix divides prediction results into four categories: true positives, true negatives, false positives, and false negatives.

ResultAbbreviationMeaningCounted as a correct prediction
True positiveTPActually positive, and the model also predicts positiveYes
True negativeTNActually negative, and the model also predicts negativeYes
False positiveFPActually negative, but the model predicts positiveNo
False negativeFNActually positive, but the model predicts negativeNo

In the context of a binary classification confusion matrix, the common accuracy formula is:

Accuracy = (TP + TN) / (TP + TN + FP + FN)

Here, the numerator represents the number of all correctly predicted samples, and the denominator represents the total number of samples.

A Simple Calculation Example

Suppose a binary classification model evaluates a total of 100 samples, and the confusion matrix statistics are as follows:

MetricQuantity
TP30
TN50
FP10
FN10

Then the accuracy is:

Accuracy = (30 + 50) / (30 + 50 + 10 + 10) = 80 / 100 = 80%

This means that among all 100 samples, 80 samples were predicted correctly by the model.

What Is the Difference Between Accuracy, Precision, and Recall?

Accuracy, precision, and recall are all key evaluation metrics in classification tasks, but they focus on different aspects. Accuracy looks at the overall proportion of correct predictions; precision focuses more on “whether the results predicted as positive are reliable”; recall focuses more on “whether the samples that are truly positive are retrieved.”

MetricQuestion it focuses onBetter suited to answer
AccuracyHow many predictions are correct among all samplesWhether the model is generally accurate in its predictions
PrecisionHow many samples predicted as positive are truly positive samplesWhether the positive cases reported by the model are trustworthy
RecallHow many truly positive samples are retrievedWhether the model missed important positive cases
F1 scoreA combined view of precision and recallOverall performance when false positives and missed detections need to be balanced

For example, in classification tasks where the number of classes is relatively balanced and the cost of errors is also similar, accuracy is usually easier to interpret. However, if the task is highly concerned with missed detections, recall needs to be examined closely; if the task is highly concerned with false positives, precision needs to be examined closely.

Key point: Classification model evaluation should not rely on a single metric. Metric selection should serve the task objective, rather than simply pursuing a higher value for a certain metric.

Which Classification Evaluation Scenarios Is Accuracy Suitable For?

Accuracy is suitable for quickly understanding the proportion of correct predictions made by a model across the overall sample set. Its calculation is intuitive, making it suitable as one of the basic metrics for evaluating classification models.

In the following scenarios, accuracy is usually easier to interpret:

ScenarioWhy accuracy is suitableStill need to note
Class distribution is relatively balancedEach class has a similar impact on the overall resultStill need to observe whether there are obvious weaknesses in individual classes
Error costs are similar across classesThe impact caused by predicting different classes incorrectly does not vary muchIf one type of error is more serious, other metrics should be added
Need to quickly compare the overall performance of modelsAccuracy can provide an intuitive overall proportion of correct predictionsIt should not be used as the only basis for decision-making
Preliminary evaluation of a classification taskIt can serve as a basic entry-point metricSubsequent analysis should continue with precision, recall, and other metrics

The advantage of accuracy is that it is intuitive and easy to communicate, especially when explaining “how many answers the model got right overall.” But in formal evaluation, it is better used as a starting point rather than an endpoint.

Limitations of Accuracy and the Problem of Sample Imbalance

Accuracy can reflect the overall correctness rate, but it needs to be interpreted carefully when samples are imbalanced. Sample imbalance means that the number of samples in some classes is significantly larger than in other classes. In this situation, even if a model mainly predicts the majority class, it may still obtain an accuracy that looks good.

For example, if negative samples far outnumber positive samples in a task, the model may perform well on the majority of negative samples but be insufficient at identifying the minority of positive samples. In this case, accuracy may still be relatively high, yet it cannot fully reflect the model’s ability to identify key classes.

When interpreting accuracy, you can first check these questions:

  • Is the class distribution relatively balanced?
  • Are the costs of prediction errors similar across different classes?
  • Is the task more concerned with false positives, or with missed detections?
  • Is it necessary to add precision, recall, or F1 score?
  • Is it necessary to examine model performance separately by class?

Key point: Accuracy is not an invalid metric, but it has conditions for appropriate use. When samples are imbalanced, error costs are inconsistent, or the task objective is biased toward a specific class, looking only at accuracy is often not sufficient.

From Classification to Object Detection: How Should Evaluation Metrics Be Combined?

In visual tasks such as object detection, evaluation usually does not rely solely on a single accuracy metric. It also involves metrics such as precision, recall, F1 score, and the precision-recall curve. The reason is that object detection is concerned not only with class judgment, but also with whether targets are detected, whether false detections occur, and whether the overall detection results meet the task requirements.

Evaluation metrics can be selected according to the logic of “task requirement → key metric → interpretation method”:

Task requirementKey metricInterpretation method
Understand whether overall classification is correctAccuracyLook at the proportion of correct predictions among all samples
Reduce false positivesPrecisionCheck whether the results predicted as positive by the model are reliable
Reduce missed detectionsRecallCheck whether truly positive targets are retrieved as much as possible
Balance false positives and missed detectionsF1 scoreObserve precision and recall together
Analyze object detection performancePrecision, recall, F1 score, precision-recall curveObserve the quality of detection results from different perspectives

In practical evaluation, accuracy can help establish an overall judgment, but the final assessment still needs to return to the task objective: if the impact of missing targets is greater, you cannot look only at accuracy; if false positives bring high costs, precision should be analyzed closely; if both are important, F1 score or related curves need to be combined for further judgment.