Concepts / Other Evaluation Metrics for Classification

Other Evaluation Metrics for Classification

Evaluating a classification model involves calculating its classification accuracy.

  • Programming

Asking How Good a Model's Answers Are

A classification model looks at an input and assigns it to a category. A spam filter might label an email as spam or not spam, and an image model might label a photo as a cat or a dog. Once a model has made a batch of these assignments, the obvious next question is how good those assignments were.

Evaluating a classification model means answering that question with a number. The number this article focuses on is classification accuracy. Before we compute anything, try to guess: if a model makes ten predictions and gets seven of them right, what share of its predictions were correct?

Matching Predictions to True Labels

Accuracy is about correctness. Each prediction either matches the true label or it does not. To see this, line up the predictions and the true labels by position. The first prediction is compared with the first true label, the second with the second, and so on. Every position gives one of two outcomes: a match or a mismatch.

Consider five emails. The model predicted spam, not spam, spam, spam, and not spam. The true labels were spam, not spam, not spam, spam, and not spam. The diagram below pairs each position's prediction with its true label. The highlighted position is the one where they disagree.

Position 1predicted spam, true spamPosition 2predicted not spam, truenot spamPosition 3predicted spam, true notspamPosition 4predicted spam, true spamPosition 5predicted not spam, truenot spam
At each position, which predicted label sits beside its true label, and where do they disagree? The highlighted position is a mismatch.

Four of the five positions match and one does not. Counting those matches is the first step toward measuring accuracy.

Turning Counts into an Accuracy Score

The source describes the calculation in three steps. Count the correct predictions. Count the total predictions. Divide the first count by the second. The result is the fraction of predictions the model got right, and it can be expressed as a fraction or a percentage.

Rule

The diagram below follows the same five-email example through the calculation. It counts the correct predictions, counts the total, divides, and then converts the result to a percentage.

Correct: 4matching positionsTotal: 5all predictions4 ÷ 5 = 0.8fraction0.8 × 100 = 80%percentagenumeratordenominatoras a percentage
How do the count of correct predictions and the total count combine into a fraction, and then into a percentage?
Worked example

Accuracy for Five Email Predictions

A spam filter makes five predictions. Four of them match the true labels. What is the classification accuracy as a fraction and as a percentage?

  1. 1
    Count the correct predictions

    Four positions have a prediction that matches the true label, so the correct count is 4.

  2. 2
    Count the total predictions

    There are five predictions in total, so the total is 5.

  3. 3
    Divide the correct count by the total

    The fraction is $\frac{4}{5}$. Keep the total in view, because the same 4 correct predictions out of 10 would mean something different.

  4. 4
    Convert the fraction to a percentage

    Multiply the decimal $0.8$ by $100$ to get $80\%$.

Result

The accuracy is $\frac{4}{5}$ as a fraction, or 80% as a percentage.

Reading Accuracy as a Fraction and a Percentage

The fraction and the percentage describe the same quantity, but they are written differently. The fraction $\frac{4}{5}$ shows both the number correct and the total in one expression. The percentage 80% is a scaled version of the same share, which is convenient for comparison but hides the total unless you state it.

The source advises that accuracy should always be reported with its total in view, and that the fraction and percentage forms should be kept clearly distinguished. A higher accuracy means a larger share of the model's predictions were correct, and a lower accuracy means a smaller share were.

Mistakes When Reading Accuracy

  • Common mistake

    Dividing by the number of correct predictions instead of the total

    What it looks like

    With 4 correct out of 5 predictions, computing 5 ÷ 4 and reporting 125%.

    Why it fails

    Accuracy is the share of all predictions that were correct, so the correct count is the numerator and the total is the denominator. A value above 100% cannot describe a share of the predictions.

    Do this instead

    Divide the correct count by the total: 4 ÷ 5 = 0.8, which is 80%.

  • Common mistake

    Reporting a percentage without its total

    What it looks like

    Saying the model is 80% accurate with no mention of how many predictions were made.

    Why it fails

    80% from 5 predictions and 80% from 500 predictions both look the same on their own, but they rest on very different amounts of evidence.

    Do this instead

    Report the total too, such as 80% (4 of 5 correct), and keep the fraction form when the total is small.

  • Common mistake

    Mixing up the fraction and percentage forms

    What it looks like

    Writing 0.8 and 80% as if they were two different accuracies, or writing 80/100 when the count was 4 out of 5.

    Why it fails

    The fraction and percentage describe the same value. Treating them as different numbers leads to confusion when comparing results.

    Do this instead

    Convert between them deliberately: multiply the decimal by 100 to get the percentage, and check that the fraction's denominator is the actual total of predictions.

  • Common mistake

    Comparing accuracies computed on different numbers of predictions as though they were equally reliable

When High Accuracy Can Mislead

Accuracy treats every prediction equally: each one either counts as a match or as a miss. That makes it simple to compute, but it also means a single number can hide what happens to particular cases. Suppose a set of ten emails contains nine that are not spam and one that is spam. A model that always predicts not spam gets nine of ten right, so its accuracy is 90%. Yet it never catches the spam email at all.

Accuracy 9 of 10(90%)always predicts not spamAccuracy 8 of 10(80%)flags one good email asspamSpam caught 0 of 1missed the spam emailSpam caught 1 of 1found the spam email
Why can the model with the higher accuracy be the one that misses the spam email entirely?

Model A has the higher accuracy, but Model B is the one that actually finds the spam. This does not change how accuracy is calculated. It is a reminder that accuracy summarizes overall correctness and says little about which kinds of predictions the model gets right or wrong. When reading an accuracy score, ask what the model is being evaluated on, and whether the single number tells the whole story.

Predicting Accuracy Before Computing It

What do you think happens?

A model makes 8 predictions and 6 of them match the true labels. What is its accuracy as a fraction, and as a percentage?

Reveal answer
Answer:

The fraction is 6/8, which simplifies to 3/4, and the percentage is 75%.

Divide the correct count (6) by the total (8) to get 0.75, then multiply by 100 to get 75%. Remember to write the total alongside the percentage, such as 75% (6 of 8 correct).

EASY

A classifier labels six photos as cat or dog. Its predictions match the true labels at positions 1, 2, 4, and 6. Write the accuracy as a fraction and as a percentage, and state the total with the percentage.

Hints
  • Count the matching positions first. Positions 1, 2, 4, and 6 are four matches.
  • The total is the number of predictions, which is six.
  • Multiply the decimal by 100 to convert to a percentage.

Key Takeaways

  • Classification accuracy is the fraction or percentage of a model's predictions that are correct.
  • To calculate it, count the correct predictions, count the total predictions, and divide the first count by the second.
  • Always report accuracy with its total in view, and keep the fraction and percentage forms clearly distinguished.
  • Accuracy treats every prediction equally, so a high score can hide poor results on particular classes of input.

Related concepts

More concepts starting with O