Class 7 · Unit 1: Three techniques · Lesson 1.1 · 40 min
Classification: which basket?
Uncle sorts a thousand apples without looking up. "Thirty years of apples taught me." Thirty years of examples — that's how AI learns to sort.
Today you will: Find the rule hiding in labelled examples · Sort apples the rule has never seen · Find out why two pairs disagree
Story
It is October, and Rahat's uncle is packing apples at the Sopore fruit mandi. Three wooden boxes stand in a row, marked A, B and C.
Hiba: “How do you know which box?”
Uncle: “Big and red goes in A. Small or pale goes in C. The rest go in B. Thirty years of apples taught me.” (without even looking up.)
Rahat: “Thirty years of examples. That's exactly how an AI learns to sort.”
Can we learn Uncle's rule from his boxes, and then sort apples he has never seen?
Watch
Classification, sorting into baskets — scan code 7.1.1 in the printed book.
Learn it
Uncle is doing classification: every apple goes into one of three boxes, and the boxes never change. He learned how from thirty years of apples that were already sorted. An AI learns the same way, only faster. We show it examples where the right box is already known, it finds the rule hiding in them, and then it sorts apples it has never seen. That last part is the whole point.
Words to know
- Classification putting each item into one group from a fixed list of groups. The answer is always a group, never a number.
- Class one of the groups, such as box A or "spam".
- Label the name of the right group for one item, such as "Grade A".
- Labelled data examples where the label is already known, like the apples Uncle has already packed.
- Features the things we measure to decide, such as an apple's size and how red it is. Good features make sorting easy.
- Training learning a rule from labelled examples.
- Model the rule that training produces. It is what sorts the new items.
Step by step: sorting walnuts
A trader in Kupwara sorts walnuts into Premium and Regular. Here are five she has already labelled:
| Walnut | Weight (g) | Shell | Label |
|---|---|---|---|
| 1 | 14 | light | Premium |
| 2 | 13 | light | Premium |
| 3 | 14 | dark | Regular |
| 4 | 9 | light | Regular |
| 5 | 10 | dark | Regular |
- Pick the features. She looks at two things: weight and shell colour.
- Look at one class. Both Premium walnuts weigh 13 g or more and have a light shell.
- Write the rule. 13 g or more and light shell → Premium. Anything else → Regular. This rule is the model.
- Sort a new walnut. A new one weighs 15 g and has a light shell, so the model says Premium. One that weighs 15 g with a dark shell is Regular.
Now you will do the same with Uncle's apples, with three boxes instead of two.
Careful: classification answers "which group?". If the question is "how much?" or "how many?", like tomorrow's snowfall in centimetres, the answer is a number. That is a different technique, regression, in Lesson 1.2.
On the laptop
You need: LibreOffice Calc · apple-grades.ods (sheet Training: 20 graded apples · sheet New: 10 ungraded)
Mission 1: Study the examples (pairs, 6 min)
- ☐1
Open
apple-grades.ods, sheet Training. Each row is one apple: size (mm) · red (%) · grade. - ☐2
Click in the table, Data → Sort, sort by Grade. Now the A's, B's and C's sit together.
- ☐3
In G2, write what every A apple has in common. In G3, the same for C. (Hint: look at the smallest A.)
Mission 2: Write the rule (pairs, 3 min)
- ☐4
Agree a rule like this — your numbers may differ: "size 70+ AND red 70%+ → A. Size under 65 OR red under 50% → C. Otherwise → B." Type it in G5. You've just trained a model in your head.
Mission 3: Sort new apples (pairs, 7 min)
- ☐5
Predict: how many of the 10 new apples will be grade A? Write your guess in G7.
- ☐6
Open sheet New. Fill the Grade column by hand using your rule.
- ☐7
Swap laptops with another pair. Where did you disagree, and why?
Finished early?
In D2 type =IF(AND(B2>=70;C2>=70);"A";IF(OR(B2<65;C2<50);"C";"B")) and drag it down to D11.
Does the formula agree with your hand grades?
No laptop today?
The teacher writes 12 apples on the board (size and red %), 8 already graded. Pairs find the rule from the 8, grade the last 4, and compare with the pair next to them.
Debate it
Uncle's rule says small apples go into box C, and C apples sell for much less. But one orchard in a high village always grows smaller apples, however good they taste.
Is the rule fair to that farmer? What feature is the rule missing?
Check yourself — practice, not a test
1. In classification, the output is:
- ○ A number, like 25.3
- ○ A group or category, like "Grade A"
- ○ A chart
- ○ A random guess
2. To train a classification model, we need examples where the correct group is already known.
- ○ True
- ○ False
3. Which of these are classification problems? (choose all)
- ○ Is this email spam or not spam?
- ○ How many centimetres of snow will fall tomorrow?
- ○ Is this leaf healthy or diseased?
- ○ Which grade box (A, B or C) should this apple go into?
4. The things a model looks at, such as the size and colour of an apple, are called ______.
Remember
Classification = learning from labelled examples, then putting new things into the right group.
Typing practice
Skill: the number row (7 min)
- On typing.com, open the number row lesson for your level.
- Today's sheet is full of numbers like
72and85, so keep your fingers on the home row and reach up to the numbers. - Then type these five lines in a blank Calc sheet, pressing Enter after each:
72·64·81·58·90 - Goal: 90% accuracy. Your own score, compared only with your own last time.