Specialty Digest

Global English editionLearners’ Study Dashboard — in development
The Knowledge Library for All

Flashcards: open the module flashcards (end-of-module review with workplace questions).

Online Courses / University Track / Learning from Data

Module 2 · Lesson 3 · Core

Accuracy for categories, and why it can mislead

Measure a classifier by the share of correct predictions and see how class balance can fool it.

  • 50 minutes
  • Serves O2
  • Assumes M2.L2

Phase 1: Prepare

Step 1 Warm-up recall

From M2.L2: which measure counts large errors more, MAE or RMSE?

Private: nothing you type here is sent or stored.

Step 2 Learning goal

By the end of this lesson you can:

  • compute accuracy by hand (Foundation);
  • find the majority baseline (Core);
  • explain how class balance can mislead (Core).

Phase 2: Teach

Step 3 A familiar example

A clinic screens for a rare condition that one patient in a hundred has. A nurse who tells every patient “you are fine” is right 99 times in 100, yet finds nobody who is ill.

Step 4 Clear explanation

When a model predicts a category, such as renewed or not, error is not a gap but a right or wrong answer. Accuracy is the share of predictions that are right: correct predictions ÷ all predictions.

PredictsRight onAccuracy
Always “renews” (majority baseline)16 of 2080%
A model17 of 2085%

Suppose 16 of 20 customers renewed. A rule that always predicts “renews”, called the majority baseline, is right on 16 of 20, an accuracy of 80%, without learning anything. A model that gets 17 of 20 right has an accuracy of 85%, which is only five points above the baseline.

Majority baseline80%Model85%Invented example: 20 customers, 16 renewed
A model only earns credit for beating the simple alternative. Here the model is five points above the majority baseline, not 85 points above zero.

So an accuracy figure means little until the class balance is known. When one class is rare, a model that never finds it can still look excellent. The clinic example is the extreme case, where accuracy of 99% hides a complete failure to find the patients who matter. Module 6 returns to this with precision and recall, which look at the rare class directly.

Step 5 Worked example (4 marks)

Out of 50 emails, 45 are genuine and 5 are spam. A filter marks every email as genuine. Find its accuracy and say what it shows.

  1. It is right on the 45 genuine emails and wrong on the 5 spam. (1 mark)
  2. Accuracy = 45 ÷ 50 = 90%. (1 mark)
  3. It catches no spam at all. (1 mark)
  4. Answer: 90%, which looks good but finds none of the spam. (1 mark)

Go deeper: the professor's notes

Accuracy means little until you know the class balance and the majority baseline.
Accuracy

Share right.

Baseline

Always the commonest.

Rare

May be missed.

Countright answersDivideby allComparemajority baselineCheckrare class
Accuracy

Rare class

ModelAccuracyFinds the rare cases?
always “fine”99%no
a screen97%yes

At work: A screening test

One patient in a hundred is ill.

  1. Compute the majority baseline.
  2. Look at the rare class directly.

What a careful practitioner decides. Never quote accuracy without the baseline.

Phase 3: Practise

Step 6 Learner practice (instant-marked)

1. Accuracy is:

2. The majority baseline always predicts:

3. 95 of 100 cases are class A. Always predicting A gives an accuracy of:

4. High accuracy with a rare class may hide:

Phase 4: Close

Step 7 Recap

  • Accuracy is the share of right predictions.
  • The majority baseline sets the level to beat.
  • Class balance decides how much accuracy means.

Step 8 Exit ticket (ungraded)

30 of 40 loans were repaid. What accuracy does always predicting “repaid” give?

Private: nothing you type here is sent or stored.

Step 9 Go further (Extension)

Find a real screening or fraud example where the rare class is what matters.

In industry: Zillow Offers: price forecast error with money attached

In November 2021 Zillow decided to wind down its home-buying business after taking a $304 million inventory write-down in the third quarter on homes bought at higher prices than it expected to sell them for. The chief executive said the company had been unable to forecast home prices three to six months out accurately enough.

Link to this lesson. Error in a forecast becomes a cost when decisions are made on it, and larger errors at longer horizons matter most.

Source: NPR, 3 November 2021; CNN reporting via KRDO, 9 November 2021

Common mistakes

MistakeWhy it fails
Quoting accuracy aloneAlways give the baseline beside it.
Ignoring a rare classIt may be the one that matters.
Treating 99 percent as always excellentCompare with always predicting the majority.

Limits. This lesson covers two classes only; more classes use the same idea.

Flashcards for this lesson (3)

Tap a card to reveal the answer. Read the question, answer it aloud or in writing first, then check yourself against the explanation.

Card 1 of 3 · What is accuracy?
Right17All20Accuracy85%
Accuracy

The share of predictions that are right: correct predictions divided by all predictions. For categories, such as renews or not.

Card 2 of 3 · Why can high accuracy mislead?
Rare class1 in 100Always no99%Findsnobody
Class balance

If one class is common, always predicting it scores high. A test for a condition that 1 in 100 has can be 99% accurate and find nobody.

Card 3 of 3 · What is the majority baseline?
PredictcommonestNeedsno modelBeatit
Majority baseline

Always predict the most common class. It needs no model and sets the accuracy any real model must beat.

Review with flashcards

Test yourself on this module with workplace flashcards and detailed answers.

Open the module flashcards