Rule-based and learning-based; three ways to learn
Rahat's rule sorted 23 apples out of 36. Can a machine do better without being told any rule?
- Write a rule-based model and score it
- Train a learning-based one
- Tell supervised, unsupervised and reinforcement apart
Rule-based and learning-based; three ways to learn
Rahat's rule sorted 23 apples out of 36. Can a machine do better without being told any rule?
- Write a rule-based model and score it
- Train a learning-based one
- Tell supervised, unsupervised and reinforcement apart
Story
Learn it
There are two ways to make a model. In the rule-based way, a person writes the rules and the machine follows them. In the learning-based way, the machine is given examples and finds the rules itself, the way Hiba's uncle learned apples without ever being taught a rule. Learning itself comes in three kinds, depending on what the machine learns from.
Words to know
the developer writes the rules. Easy to read, needs no data, but its learning is static: shown something new, it fails and never learns from the mistake. Example: a help-desk chatbot that only answers questions its rules expect.
the machine finds the rules from examples, and can keep improving as new examples arrive. Example: a spam filter trained on emails people marked.
learns from labelled data: every example comes with its answer, like coins labelled by currency, with weight as the feature.
finds patterns in unlabelled data on its own, like groups of customers nobody named.
learns by trial and error, from reward and penalty, like a robot learning to walk.
Step by step: scoring a rule
Five walnuts, and a rule: if weight ≥ 12 g, grade A, else grade C.
| Walnut | Weight | Real grade | Rule says | Right? |
|---|---|---|---|---|
| 1 | 14 | A | A | ✓ |
| 2 | 9 | C | C | ✓ |
| 3 | 13 | C | A | ✗ |
| 4 | 11 | A | C | ✗ |
| 5 | 12 | A | A | ✓ |
- Write the rule as a formula:
=IF(B2>=12;"A";"C"). - Check each row against the real grade:
=IF(D2=C2;1;0). - Count the correct ones: 3 out of 5.
- Look at the misses: walnut 3 is heavy but cracked; walnut 4 is light but perfect. Weight alone can't see that.
- The learning-based alternative: give a model many labelled walnuts with all their features, and let it find the pattern, including ones no one would think to write.
Careful: unsupervised does not mean no human is involved: a person still chooses the data and decides what the groups mean. And reinforcement is not supervised learning with extra steps. No labels are given at all, only a score for what the machine did.
Your missions
datasets/apples.csv · Teachable Machine · three-ways.odsYour rule, scored
12 minin pairs- 1
Open
apples.csv. In G1 typerule, and in G2 type Rahat's rule:=IF(C2>=70;"Delicious";"Ambri"). Fill it down to row 37. - 2
In H2, check it:
=IF(G2=F2;1;0). Fill it down. In H38,=SUM(H2:H37)counts the correct ones. It should say 23. - 3
Predict: can you write a rule that beats 23? Write your target number in J1.
Only you can see this - 4
Write your own rule in G2, using any features you like. You can put one IF inside another:
=IF(B2<=180;"Ambri";IF(…;…;…)). Keep your best score, and the rule that got it.
Learning from examples
10 minin pairs — *online*- 5
Open Teachable Machine → Image Project. Name Class 1
healthyand Class 2scab. - 6
Upload the photos from
datasets/leaves/healthyanddatasets/leaves/scab. Press Train. - 7
Test it with the photos in
datasets/leaves/new. It was never given a rule — only labelled examples. Which kind of learning is that?
Three ways to learn
5 min- 8
Sheet Tasks in
three-ways.ods: nine tasks. Write supervised, unsupervised or reinforcement beside each.
Find the two apples your best rule gets wrong. Is there any rule that could get them right, or do they just look like the wrong variety?
No laptop today?
Put ten apples' numbers on the board. Each pair writes a rule and scores it on the board's ten. Then your teacher shows the leaf model on one screen, if one is working, and the class sorts the nine tasks aloud.
Debate it
Hiba's uncle can sort apples but cannot say his rule. A model trained on his sorting might learn it — but might not be able to say it either.
- Is a rule you can read better than a rule that works better? When?
- If the model made a mistake, who could the farmer argue with?
Check yourself · practice, not a test
In the app, students answer these one at a time and each answer is checked straight away. It's practice, never a mark — anything they miss comes back later for another go.
1.In a rule-based model, who decides the rules?
- AThe machine, from examples
- BThe developer, who writes them
- CThe users, by voting
- DNobody; they are random
2.Match each task to its kind of learning:
- Learning to sort leaf photos from photos labelled healthy and scab
- Finding groups of shoppers nobody has named
- A robot learning to walk by falling and trying again
- Reinforcement
- Unsupervised
- Supervised
3.A rule-based model improves by itself when it makes a mistake.
TrueFalse4.Supervised learning needs ______ data.
5.Put the steps of Part 1 in order:
- 1Add up the correct rows
- 2Check each row against the real variety
- 3Write the rule in column G
- 4Try a better rule and compare the score
A rule is written. A model is trained. Both must be scored.
Typing practice
Skill: a formula with brackets inside brackets (5 min)
-
On typing.com: the symbols lessons.
-
Type three times, eyes on the screen:
=IF(C2>=70;"Delicious";"Ambri") -
Count the quotation marks: there must be four. Goal this term: 38–44 WPM at 95%.
Written and designed by Faizan Ayoub. © 2026 Faizan Ayoub. All rights reserved.