Accuracy from the Matrix
This is the easiest score to calculate and the easiest to be fooled by. Both halves of that sentence are examined.
1The formula
Accuracy = Correct predictions / Total predictions
= (TP + TN) / (TP + TN + FP + FN)
Multiply by 100 for a percentage.
The top of the fraction is the two True cells. The bottom is all four cells, which is just the size of the test set.
2Where accuracy lies to you
Now the part that matters. Suppose you test a model on 1000 students. In reality 900 pass and only 100 fail — an unbalanced dataset. And suppose you have built a deliberately faulty model that, whatever input it is given, always answers “Yes, they pass”.
It never looks at the input at all. What accuracy does it score?
Pick a metric to light up the cells it is built from. Precision is the top row; recall is the left column.
| Actual / Reality | ||
|---|---|---|
| Yes | No | |
| Predicted Yes | TP 900 | FP 100 |
| Predicted No | FN 0 | TN 0 |
The model that always says Yes. Positive class: Student passes. It never looks at the input, yet it scores 90% accuracy — because 900 of the 1000 students really did pass. This is why accuracy alone cannot be trusted on an unbalanced dataset.Source: Class X handbook, Activity 3
Forecasting sunshine in a desert
3When accuracy can be used
When the data is unbalanced, use precision, recall or the F1 score instead. Those are the next two lessons.
4From the board papers
(a) Draw the confusion matrix. (b) Calculate the accuracy, showing your working. (c) Write the total number of wrong predictions.CBSE sample paper 2025–26
▶Show the answer
(a) Taking “passes” as the positive class: TP = 40, FP = 20, FN = 10, TN = 30.
| Actual: Pass | Actual: Fail | |
| Predicted: Pass | 40 | 20 |
| Predicted: Fail | 10 | 30 |
(b) Accuracy = (TP + TN) / total = (40 + 30) / 100 = 70/100 = 0.7 = 70%.
(c) Wrong predictions = FP + FN = 20 + 10 = 30. (And 70 + 30 = 100, which checks out.)
▶Show the answer
Accuracy. It is the only one of the four whose numerator is both True cells, TP + TN. Precision and recall each use TP only.
▶Show the answer
Classification accuracy is the number of correct predictions as a ratio of all predictions made, that is (TP + TN) / (TP + TN + FP + FN).
No, it cannot be used at all times. It is only suitable when the dataset is balanced and when all prediction errors matter equally. On an unbalanced dataset a model that always predicts the majority class can score very high accuracy while being useless, so precision, recall or F1 score should be used instead.
▶Show the answer
TP = 40, FN = 50 − 40 = 10, FP = 30, TN = 950 − 30 = 920.
Accuracy = (40 + 920) / 1000 = 960/1000 = 0.96 = 96%.
The textbook’s four options are 97%, 90%, 85% and 70% — none of which is the answer to its own question. Work it from the formula and write 96%. Notice too how high that number is while the test missed 10 of the 50 sick people: 950 of the 1000 were healthy, so this is an unbalanced dataset and accuracy is flattering it.
5Check yourself
What is the formula for classification accuracy?
When is accuracy NOT a suitable metric?
A model tested on 1000 samples has TP = 200, TN = 600, FP = 100, FN = 100. Its accuracy is: