Class 9 · Unit 1: The AI project cycle, and ethics · Lesson 1.4 · 40 min
Modelling and evaluation
The sticky note says 94%. Hiba tests it on twenty real leaves. One mistake could cost an orchard its season.
Today you will: Write a rule-based model · Build a 2×2 table from real results · Say which mistake costs more, and to whom
Story
The leaf checker from last year still sits on the club laptop. Somebody has written 94% on a sticky note on the lid.
Hiba tests it on twenty leaves from an orchard in Shopian, writing down what the model said and what the leaf actually was. Then she draws a square divided into four.
The model called twelve healthy leaves healthy. It called five scabbed leaves scabbed. It called two healthy leaves scabbed — the grower would spray trees that did not need it. And it called one scabbed leaf healthy.
Rahat: “Eighty-five per cent. Still fine.” (reading the total.)
Hiba: “Look at the last box again. That one leaf is how an orchard loses a season. Two of these mistakes are not the same size.”
Watch
Two kinds of model, and four kinds of result — — scan code 9.1.4 in the printed book.
Learn it
Stage four is modelling, and a model can be built two ways: a person writes the rules, or the machine learns them from labelled examples. Stage five is evaluation, and it is more than one percentage. Every prediction lands in one of four boxes, and the two kinds of mistake (a false alarm and a miss) almost never cost the same. "94%" on a sticky note hides exactly that.
Words to know
- Modelling stage four: building the model that makes the predictions.
- Rule-based model a person writes the rules (if snowfall > 10 cm and the road is not cleared, predict low attendance). You can read it, argue with it and fix one line.
- Learning-based model the machine finds the rule from labelled examples. Nobody wrote it, and nobody can read it back.
- Evaluation stage five: checking the model's predictions against what really happened.
- Positive the thing you are looking for, such as a leaf with scab. Decide this first.
- True Positive (TP) / True Negative (TN) — correct: scab called scab; healthy called healthy.
- False Positive (FP) a false alarm: a healthy leaf called scabbed.
- False Negative (FN) a miss: a scabbed leaf called healthy.
- Accuracy (TP + TN) ÷ total × 100. It treats both mistakes as equal.
Step by step: a 2×2 table for a fever checker
Positive = the child has a fever. Twenty children are checked:
| Checker said fever | Checker said no fever | |
|---|---|---|
| Actually fever | TP = 4 | FN = 1 |
| Actually no fever | FP = 3 | TN = 12 |
- Fill the boxes by comparing each prediction with reality.
- Accuracy = (4 + 12) ÷ 20 × 100 = 80%.
- Read the mistakes, not just the total: 3 false alarms (a child sent to the nurse for nothing) and 1 miss (a sick child sent back to class).
- Decide which matters more: here the miss does. A different checker with fewer misses and more false alarms may be the better one, even at the same accuracy.
Rule-based is not a lesser choice. If you can write the rule, write it: it is cheap, explainable and needs no training data. Use a learned model when the rule is too hard to write down.
🕌 From our heritage
Ibn Sīnā (980–1037) set out rules for testing whether a remedy really works, in the Canon of Medicine. One of them says that the trial must be repeated: if the effect appears only once, it may have been an accident, not the remedy at all. He also warned that a drug tested on a single complicated case tells you nothing, because you cannot say what caused what. Twenty leaves, honestly recorded, is that rule applied to a model — and the sticky note saying 94% is the single lucky trial he was warning about.
Source: Ibn Sīnā, al-Qānūn fī al-Ṭibb (c. 1025), Book II, on testing the effects of remedies.
Careful: a false positive does not mean the model is lying. It flagged something that turned out fine, and for a screening tool that is sometimes exactly what you want. And labelling the four boxes depends on which class you call positive: decide that first and write it at the top.
On the laptop
You need: LibreOffice Calc · leaf-results.ods (sheets Rules, Results, Matrix)
Mission 1: A rule-based model (8 min, in pairs)
- ☐1
Sheet Rules: write a rule-based model for winter attendance as three or four
if … then …lines. - ☐2
Beside it: what data does your rule need? What would a learning-based model need instead?
- ☐3
Mark the line everyone would argue about. A learning-based model would have decided it for you, silently.
Mission 2: The 2×2 table (12 min)
- ☐4
Sheet Results: twenty leaves — what the model said, what each really was.
- ☐5
In a cell, write what positive means: the leaf has scab.
- ☐6
Predict: which box will be biggest? Which smallest?
- ☐7
Sheet Matrix: fill the four counts with
COUNTIFS. Actual down the side, model said across the top:Model said scab Model said healthy Actually scab True Positive False Negative Actually healthy False Positive True Negative - ☐8
Accuracy:
=(TP+TN)/20*100. Then answer below the grid: which box would you shrink first — and what does the grower do after each kind of mistake?
Finished early?
Two models both score 85%. One makes only false positives, the other only false negatives. Which would you give the grower?
No laptop today?
Draw the grid on the board. Your teacher reads the twenty results; everyone tallies in their notebook, then works out the counts and accuracy by hand.
Debate it
A hospital screening model is meant to catch a disease early.
- Would you rather it made false positives or false negatives? What happens to the patient in each case?
- The disease affects one person in a hundred. Describe a useless model that is "99% accurate".
- Who should decide the balance between the two mistakes — the engineer, the doctor, or the patient?
Check yourself — practice, not a test
1. Match each result to its name. Positive = the leaf has scab.
Scabbed leaf, model said scabbed · Healthy leaf, model said scabbed · Scabbed leaf, model said healthy · Healthy leaf, model said healthy
Match with: False Positive · False Negative · True Negative · True Positive2. An orchard model misses scab on infected trees. Which box is filling up?
- ○ True Positive
- ○ False Positive
- ○ False Negative
- ○ True Negative
3. Two models with the same accuracy are equally good.
- ○ True
- ○ False
4. A model whose rules are written by a person, not learned from data, is called ______-based.
5. When is a rule-based model the better choice? (choose all that apply)
- ○ When a person can state the rule clearly
- ○ When there is no training data
- ○ When someone must be able to read and argue with the logic
- ○ When the problem involves recognising faces in photographs
Remember
Accuracy hides which mistake you are making. The four boxes show it.
Typing practice
Skill: the colon and the comparison operators (5 min)
-
typing.com symbols lessons, focusing on
:,>,<and=. -
Type this three times. It is the rule-based model you will write out in Part 1, in the form Unit 5 will use:
if snowfall_cm > 10: -
Term 1 goal: 32–38 WPM at 94% accuracy.