Class 7 · Unit 1: Three techniques · Lesson 1.4 · 40 min
Training and testing: keep some back
Rahat memorised last year's paper: 100% at home. New questions in the real exam: 41%. Machines make the very same mistake.
Today you will: Split data into train, validate and test · Train a real leaf model in Teachable Machine · Score it only on photos it has never seen
Story
Before the maths exam, Rahat found last year's paper and learned every answer by heart. In his practice at home he scored 100%.
Then the real exam came, and the questions were new. He scored 41%.
Hiba was kind about it. "You didn't learn maths, Rahat. You learned that paper."
Machines can make exactly the same mistake. That's why AI builders always keep some data hidden until the very end.
How do we know whether a model has really learned, or just memorised?
Watch
Training, validation, test — scan code 7.1.4 in the printed book.
Learn it
Rahat scored 100% at home and 41% in the exam, because he had learned that paper, not maths. A machine can make the same mistake: it can memorise its examples instead of learning the pattern. So AI builders split their data into three parts and keep one part hidden until the very end. Only a score on data the model has never seen tells you how it will do in the real world.
Words to know
- Dataset a collection of data used to teach and check a model.
- Data point (or record) — one item in a dataset, such as one photo or one row, with its features.
- Training dataset the part the model learns from, like studying your notes.
- Validation dataset the part used to check and improve the model while it trains, like practice sums.
- Test dataset the part kept back for the final check, on data the model has never seen, like the real exam.
- Memorising doing well on the examples you studied but badly on new ones. It looks like learning, but it isn't.
- Test accuracy the share of test items the model gets right, written as a percentage.
Kinds of datasets
| Type | What it holds | Kashmiri example |
|---|---|---|
| Numerical | numbers | daily milk from a dairy |
| Text | words | messages in a class group |
| Multimedia | images, audio, video | photos of chinar and willow leaves |
| Time-series | readings over time | Srinagar's temperature every month for 30 years |
| Spatial | places and locations | GPS points of every school in Baramulla district |
By shape: structured data fits neat rows and columns (a marks table); unstructured data does not (photos, voice notes); hybrid data mixes both (a shop's sales table plus photos of each product).
Step by step: a 60 / 20 / 20 split
You have 50 photos of walnut leaves.
- Training, 60%: 60% of 50 = 30 photos. The model learns from these.
- Validation, 20%: 10 photos. Check while training; if it gets many wrong, add examples or train longer.
- Test, 20%: 10 photos, locked away until the end.
- The final exam: show the model the 10 test photos once. 9 right out of 10 = 90% test accuracy.
Careful: validation and test are not the same thing. Validation is the practice sums: you can look at the result, change the model and try again. The test is the final exam, used once, at the end. And 100% on the training data does not mean the model is perfect; it may only have memorised.
On the laptop
You need: Teachable Machine in the browser (no account) · LibreOffice Calc · leaves/chinar/ and leaves/willow/ (30 photos each, already split: train 18 · validation 6 · test 6) · leaf-test.ods
Mission 1: Train (pairs, 6 min)
- ☐1
Teachable Machine → Get Started → Image Project → Standard image model. Rename the classes
ChinarandWillow. - ☐2
Upload the 18
trainphotos into each class. Click Train Model — don't switch tabs.
Mission 2: Check and improve (pairs, 5 min)
- ☐3
In Preview, switch Webcam to File. Try the 12
validationphotos. How many right? - ☐4
If several are wrong, add training photos or raise Epochs (under Advanced), and train again.
Mission 3: The final exam (pairs, 6 min)
- ☐5
Predict: what score will it get on photos it has never seen? Write it at the top of
leaf-test.ods. - ☐6
Try the 12
testphotos once each. Type the model's answer andYesorNofor right. - ☐7
Score:
=COUNTIF(C2:C13;"Yes")/12, as a percentage. That's your test accuracy. 🔒 Teachable Machine trains inside your browser. Don't click Export Model or save to Drive.
No laptop today?
The quiz-master game. Write 15 "What am I?" cards about leaves or fruit. Show a volunteer 9 cards (training), then 3 with feedback (validation), then 3 they've never seen (test). Which did they do best on? Why does that matter?
Debate it
A company says its apple-disease model is "99% accurate!" but it tested the model on the same photos it trained on.
Should an orchard farmer trust that number? What question would you ask the company?
Check yourself — practice, not a test
1. Put the three parts of a dataset in the order they are used:
- 1. Validation dataset
- 2. Test dataset
- 3. Training dataset
2. Which part of the dataset is used for the final check of the model?
- ○ Training
- ○ Validation
- ○ Test
- ○ All of them together
3. The model should see the test photos many times while it is training.
- ○ True
- ○ False
4. Match each dataset to its type:
Srinagar's temperature every month for 30 years · Photos of chinar and willow leaves · GPS locations of all the schools in Baramulla district
Match with: Multimedia dataset · Spatial dataset · Time-series dataset5. You have 100 images. With a 60/20/20 split, ______ images are used for training.
Remember
Train on some, check on some, test on data the model has never seen.
Typing practice
Skill: numbers and the % sign (7 min)
- On typing.com, practise the number row and symbols.
- Type these into Calc:
60%·20%·20%·=18/30·=6/30(The%sign is Shift + 5.)