Lesson 2 of 5 · Open
Learning from examples
Instead of writing rules, you show the machine examples.
How do you recognize a cat in a photo? You see it at once. But try to write down the rule for it: fur, four legs, pointed ears? That fits many dogs too. And in some photos the cat is curled up, sits in the shade, or is only half visible.
A program needs a rule to decide by. For a long time that meant: a person works out the rule and writes it in by hand. With photos, speech, or handwriting this works poorly, because the rules can hardly be put into words.
For such tasks people take a different route: they show the program many examples and let it find the rule itself. This is called machine learning. The program is then called a learning system.
| Question | Written rule | Learned from examples |
|---|---|---|
| What does the person supply? | the finished rule | examples with the right answer |
| Who finds the rule? | the person | the system |
| When does this way fit? | when the rule is clear | when it can hardly be written down |
| What is a typical case? | password valid from 8 characters | cat or dog in a photo |
Example and label
An example has two parts: the thing the system should judge, and the right answer for it. That answer is called the label. A photo with the word cat is one example, the word cat is its label. Often a person assigns the labels. All examples together are called the training data.
Learning with labels is called supervised learning. There are also methods that learn without labels. This lesson does not cover them.
From examples to a model
With the training data, training begins. The system looks for a pattern: something that examples with the same label have in common and that sets them apart from the others. Nobody tells it what to look at. The result of training is called the model. It holds the pattern that was found and is the rule that nobody had to write down.
New terms
- example
- something the system should judge, together with the right answer
- label
- the right answer for one example
- training data
- all the examples together that the system learns from
- training
- the phase in which the system looks for a pattern in the examples
- pattern
- what examples with the same label share and what sets them apart from the others
- model
- the result of training: the rule it found, which answers new cases
Quick check
What answers a new photo without a label?
Example
Cat or dog
A program is supposed to sort photos into cats and dogs. It is built from examples in four steps.
- Collect: 2,000 photos of cats and dogs.
- Label: each photo gets its label, the word cat or dog.
- Train: the system looks for what separates cat photos from dog photos.
- Use: the model gets a new photo without a label and answers on its own: cat.
Example
In everyday life: the spam filter
An email service collects which emails its users mark as spam and which they do not. The mark is the label. In training the system finds, for example, that certain words and senders often come with spam. When a new email arrives, the model decides on its own: spam or not spam.
The examples set the limit
The system has nothing but its examples. It cannot learn what is missing there. A system that has seen only printed digits often misreads handwritten digits. Even more printed digits hardly change that. It needs examples of handwriting, each with a label.
Typical mistake
Assuming the system pays attention to the animal without being told to. That cannot be right: nobody told it what matters. If every dog photo was taken outdoors and every cat photo indoors, the background goes with the label just as well as the animal does. A dog on the couch then easily becomes a cat.
Remember
Tasks
Task 1 · Sorting
Written rule or learned from examples? Sort each case.
5 cards left
Task 2 · Order
A system should recognize birds by their song. Put the steps in the order they happen.
- 1Collect recordings of birdsong
- 2Note the bird species as the label for each recording
- 3The model answers: blackbird
- 4The system looks for the pattern in training
- 5The model gets a new recording without a label
Task 3 · Choice
Every wolf photo in training shows snow, every dog photo a meadow. New photo: a dog in the snow. What can easily happen?
Go deeper
Task 4 · Pairs · optional
A system should match leaves to their tree species. What is what here?
Task 5 · Fill in · optional
A voice assistant understands children poorly. Fill in the words so that the explanation holds.
It was trained almost entirely on the voices of . So its hold hardly anything about children. What would help is recordings of , each with the right .
Task 6 · Several right · optional