How machines learn from examples
Years 6 to 13
A machine learning program finds patterns in labelled examples, then uses them to decide about something new.
For learners
Instead of being told the rules, a machine learning program is shown lots of examples with labels, like photos marked 'cat' or 'dog'. It looks for what the groups have in common.
To label something new, one simple method looks for the closest labelled example and copies its label. This is called nearest neighbour.
To check how well it works, we test it on new examples it has never seen, and count how many it gets right. That share is its accuracy.
A worked example
A model is tested on 50 new pictures and gets 40 right. What is its accuracy?
- Right answers divided by total: .
- .
- The accuracy is 80%.
For grown-ups
Nearest neighbour is the easiest machine learning method to follow: 'you are probably like the things you are close to'. With k neighbours, the computer takes a vote. Testing on new examples matters: a model tested only on its training data can look perfect and still fail in real life.
Common mistakes
- Testing a model on the same examples it learned from.
- Using only a few examples, so one odd example misleads the model.
- Judging by accuracy alone when one group is much rarer than the other.
Why it matters
Spam filters, photo apps and voice assistants all learn from examples rather than from hand-written rules.
Topics in quarter that use this
- How computers learn from examples
- Nearest neighbour: how a machine decides
- How good is the model?
- Probability and the spam filter