Course 9, lesson 86 of 100, Ages 14+
Train your own classifier
From examples to a working model
Like I’m 5
You can teach a computer to tell things apart, like thumbs up from thumbs down, by showing it examples of each. That's training a classifier.
The big idea
Pick a clear task with a few categories, collect balanced examples of each, and split them into training and test sets. No-code tools like Teachable Machine let you do this with a webcam in minutes.
Train, then check the test accuracy and the confusion matrix, which shows which classes get mixed up. If 'rock' is often mistaken for 'paper', add more varied examples of both. Simple, well-tested models often beat complicated ones.
Examples
- Gesture game: Thumbs up, thumbs down and wave, trained with a webcam.
- Plant health: Healthy leaf versus spotty leaf photos.
- Confusion matrix: Shows that 'cat' is sometimes predicted as 'fox'.
How it works
- Choose classes and collect balanced, varied examples.
- Train on one part of the data and keep a test set aside.
- Measure accuracy, find confusions and improve the data.
Check your understanding
- What does a confusion matrix show?
- Options: Which classes the model mixes up; The model's favourite colour; How fast the computer is.
Answer: Which classes the model mixes up. It counts correct and incorrect predictions per class. - Rock is often mistaken for paper. What's a good fix?
- Options: Add more varied examples of both; Delete the test set; Rename the classes.
Answer: Add more varied examples of both. Better data targets the specific confusion.
Remember
Balanced data, a held-out test set and a confusion matrix make a trustworthy classifier.
Talk about it
What three things would you train a classifier to tell apart?
Go deeper
Beyond accuracy, use precision, recall and F1, especially with imbalanced classes. Transfer learning, starting from a pre-trained network, lets small datasets work well.