Accuracy

Accuracy is a measure of how well a model is able to correctly predict the outcome or class of a given observation.

It is a metric used to evaluate the performance of classification models.

How to calculate

Accuracy is calculated by dividing the number of correctly predicted instances by the total number of instances in the dataset.

The result is usually expressed as a percentage.

Example

Suppose we have a binary classification problem where we are trying to predict whether an email is spam or not. We train a model on a dataset of 1000 emails, 500 of which are spam, and the remaining 500 are not. If the model predicts 450 emails correctly (i.e., 225 spam emails and 225 non-spam emails), the accuracy of the model is:

Accuracy = (225 + 225) / 1000 = 0.45 or 45%

Note

While accuracy is a popular metric for evaluating classification models, it may not always be the best metric.

Especially in cases where the dataset is imbalanced, meaning one class has a much smaller representation than the other.

In such cases, accuracy can be misleading, as a model that always predicts the majority class will have high accuracy, but may not be useful in practice.

In such cases, other metrics such as precision, recall, F1-score, or area under the receiver operating characteristic (ROC) curve may be more appropriate.

Related Topics