Notes

Accuracy

When you build a classifier, you naturally want a simple answer to: “How many did it get right?” Accuracy is that first, comforting checkpoint—useful, but only when you understand what it’s actually counting (and what it’s ignoring).

What accuracy measures

Accuracy is the fraction of predictions that exactly match the true class label. If you have N labeled examples and your model predicts the correct label on K of them, then accuracy is K / N. In binary classification, it can be written using the confusion matrix as:

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

So it rewards both correct positives (TP) and correct negatives (TN) equally.

Why it can mislead

Accuracy matters because it’s easy to compute and compare, and many tools report it by default. But it breaks down when classes are imbalanced or when different errors have different costs. For example, in fraud detection where only 1% of transactions are fraud, a model that predicts “not fraud” for everything gets 99% accuracy—yet it’s useless. In disease screening, missing a sick patient (false negative) is typically worse than a false alarm (false positive), and accuracy doesn’t reflect that asymmetry.

How it’s used in practice

You’ll see accuracy in libraries like scikit-learn as a quick metric:

from sklearn.metrics import accuracy_score
acc = accuracy_score(y_true, y_pred)

It’s most appropriate when classes are reasonably balanced and error costs are similar—like basic spam vs. not-spam filters in a balanced dataset—while metrics like precision, recall, or ROC-AUC become essential when they aren’t.

Accuracy is the proportion of predictions a classifier gets correct: (number of correct predictions) ÷ (total predictions), equivalently (TP + TN) ÷ (TP + TN + FP + FN) from the confusion matrix. It matters because it provides a simple, baseline measure of overall classification performance and is widely used for model selection and reporting, but it can be misleading under class imbalance or unequal error costs.

Think of a multiple-choice quiz: you got 8 questions right out of 10. Your score is 80%. In AI classification, accuracy is that same idea: the share of times the model’s guess matches the correct label.

For example, a spam filter might label emails as “spam” or “not spam.” If it gets 95 out of 100 emails right, its accuracy is 95%.

Accuracy is popular because it’s simple and easy to explain. But it can be misleading when one class is rare—like fraud detection—because a model can look “accurate” while still missing most fraud cases.