Class 10 · Unit 3: Evaluating models · Lesson 3.2 · 40 min
Accuracy and error
Rahat built a leaf model in two seconds. It's 75% accurate. It has never caught a single scabbed leaf.
Today you will: Work out error and accuracy for a price · Work out accuracy for classes · Catch a lazy model hiding behind a good number
Story
The exhibition team have tested their leaf app properly this time, on 60 new photos. The new sign says 83% accurate.
Rahat is not impressed. "I can beat that in two seconds."
He writes a model on a scrap of paper. It has one rule: always say healthy.
Hiba checks it on the same 60 photos. Most leaves in spring are healthy, so most of the time he is right.
Hiba: “Seventy-five per cent. Nearly as good as theirs.”
Rahat: “Told you.”
Hiba: “Rahat. Your model has never found a scabbed leaf in its life.”
Watch
How right, how wrong — — scan code 10.3.2 in the printed book.
Learn it
Error is how far a model's prediction is from what really happened, and accuracy turns that into a score. For a model that predicts numbers, error is the size of the miss. For a model that predicts classes, accuracy is the share it got right. But accuracy has a trap: when one class is far more common, a model that always guesses the common answer scores well and is completely useless.
Words to know
- Error for a number: |actual − predicted|, the size of the miss, with no minus sign.
- Error rate error ÷ actual.
- Accuracy 1 − error rate (× 100 for a percentage).
- Classification accuracy correct predictions ÷ all predictions.
- Unbalanced dataset one class is far more common than the other, like 900 Yes and 100 No.
- Lazy model a "model" that always predicts the commonest class. On unbalanced data it can look accurate.
Step by step: two kinds of accuracy
A number. A model predicts a box of walnuts will fetch ₹1,500; it actually fetches ₹1,600.
- Error = |1,600 − 1,500| = ₹100.
- Error rate = 100 ÷ 1,600 = 0.0625.
- Accuracy = 1 − 0.0625 = 0.9375 = 93.75%.
Classes. A fever checker is tested on 50 children: 5 really have fever, 45 don't.
- The real model gets 44 right → 44 ÷ 50 = 88%.
- The lazy model, "always say no fever", is right on all 45 healthy children → 45 ÷ 50 = 90%, higher, and it never finds a single child with fever.
Aim: maximise accuracy, minimise error. No real model reaches 100%.
Careful: an error is a size, not a direction. CBSE takes the absolute value, so missing by ₹100 above or below is an error of ₹100 either way. And "83% accurate" does not mean 83% on every kind of leaf: it is an average over all of them.
On the laptop
You need: LibreOffice Calc · datasets/mandi-prices.csv · datasets/leaf-predictions.csv
Mission 1: Error for a number (10 min, in pairs)
- ☐1
In
mandi-prices.csv, a model learned from weeks 1–12 only. Its trend is: price = 617.6 + 18.93 × week. In C14, predict week 13:=617.6+18.93*A14. Fill down to week 16. - ☐2
Predict: which of weeks 13–16 will the model get most wrong? Write it in F1.
- ☐3
In D, E and F work out error
=ABS(B14-C14), error rate=D14/B14and accuracy=1-E14. Then the mean accuracy of the four weeks.
Mission 2: Accuracy for classes (7 min)
- ☐4
Open
leaf-predictions.csv: 60 leaves, with what each really was (actual) and what the model said (predicted). - ☐5
Count the correct ones:
=SUMPRODUCT(C2:C61=D2:D61). Divide by 60. That is the model's classification accuracy. What is its error rate?
Mission 3: Rahat's lazy model (6 min)
- ☐6
In E1 type
lazy. Fill E2:E61 with the wordhealthy. - ☐7
Work out the lazy model's accuracy the same way. Then count how many scab leaves it caught:
=COUNTIFS(C2:C61;"scab";E2:E61;"scab"). - ☐8
In H1 finish: "The lazy model is … % accurate and catches … scabbed leaves, because …"
Finished early?
How many healthy leaves would there need to be, out of 60, for Rahat's lazy model to score higher than the real one?
No laptop today?
Do the two traders from the video on the board, step by step. Then your teacher reads 20 leaves (actual and predicted). Tally the correct ones, then score "always healthy" on the same 20.
Debate it
Hospitals test for diseases that most people don't have.
- A test that always says "you're fine" would be very accurate. Why would it be the worst test in the hospital?
- What would you want to know about a test, apart from its accuracy?
Check yourself — practice, not a test
1. A model predicts ₹900; the real price is ₹1,000. What is the error?
- ○ ₹900
- ○ ₹100
- ○ 0.9
- ○ 10%
2. Accuracy = 1 − ______ rate.
3. A model that always predicts the most common class can have a high accuracy and still be useless.
- ○ True
- ○ False
4. A model is right on 45 of 60 leaves. Its classification accuracy is:
- ○ 45%
- ○ 60%
- ○ 75%
- ○ 15%
5. A dataset where one class is far more common than the other is called:
- ○ Labelled
- ○ Unbalanced
- ○ Clustered
- ○ Continuous
Remember
Accuracy is the first question about a model, never the last.
Typing practice
Skill: a formula with ABS (5 min)
-
On typing.com: the symbols lessons.
-
Type three times, eyes on the screen:
=1-ABS(B2-C2)/B2 -
Goal this term: 38–44 WPM at 95%.