Data science

Accuracy

Accuracy is the proportion of correct predictions (both true positives and true negatives) out of all predictions.

Ask the Data science assistant1 min read · Updated September 9, 2026

Definition

Accuracy=TP+TNTP+TN+FP+FN\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN}, the fraction of predictions that are correct.

Accuracy alone is misleading for imbalanced datasets — a model predicting "not fraud" 99% of the time has 99% accuracy.

Intuition

Use accuracy when classes are roughly balanced and all errors have similar costs.

For skewed classes, accuracy can be gamed by predicting the majority class — always check the confusion matrix.

Worked example

99 fraud cases out of 10,000: predicting "no fraud" for all gives 99.01% accuracy but zero recall for fraud.

A medical test with 95% accuracy means 5% of sick patients are misdiagnosed — is that acceptable?

The math

Accuracy is the complement of the error rate: Error Rate=1−Accuracy\text{Error Rate} = 1 - \text{Accuracy}.

For KK-class classification, accuracy is 1n∑i1{y^i=yi}\frac{1}{n}\sum_i \mathbf{1}\{\hat{y}_i = y_i\}.

In practice

Appropriate when baseline (predicting majority class) is the main competitor and classes are balanced.

Always report alongside precision, recall, and F1 when publishing results.

Go deeper

More in Data science

Assembled from the ReLU.chat curated knowledge base. These explanations are concise on purpose; check the sources for anything important.