Data & AI
How machines learn
Learning sounds mysterious but it is arithmetic: a model makes predictions, measures its error and keeps adjusting numbers until the error gets small.
When people say a machine has learned something, it sounds like a thinking being. In reality the process behind it is very sober: a program with adjustable numbers makes predictions, compares them with the correct answer and shifts the numbers a small step so it is less wrong next time. That is all. In this topic we look at this process closely, without magic and without hype.
A model is a formula with adjustable knobs
In classic programs a human writes down the rules. In machine learning the human instead only writes down the shape of the solution, for example: the answer is a line that separates two groups of points. Where exactly that line sits is determined by a few numbers, the parameters. A straight line needs only two of them: its slope and its height on the vertical axis. Large have billions of such parameters, but the idea stays the same: the model is a formula and the parameters are its knobs. Learning means finding good values for these knobs.
Training means shrinking the error
How do you find good values? You measure how bad the current ones are. The model gets an example with a known answer, makes its prediction, and the difference from the correct answer is the error. In tasks that answer yes or no, every prediction is either right or wrong. Dividing the number of wrong predictions by the number of all examples then gives the error rate. Then comes the crucial trick: you can compute in which direction each knob must be turned so the error drops a little. So you turn all knobs a tiny step in that direction and repeat the whole thing, thousands or millions of times, with ever new examples. The error sinks step by step, like a ball slowly rolling to the lowest point of a bowl. When it barely sinks any more, training is done. A finished model can later be trained further on a small, specialised set of examples so it does better on one particular job. That is called fine tuning.
The machine learns a boundary from examples. A perfect split is often impossible.
With a teacher or without
The setup with known answers is called supervised learning: every training example carries a label, say spam or not spam, and the model learns to predict the label. There is also unsupervised learning, entirely without labels. Here the model searches for structure in the data on its own, for example: these thousand customers fall into three groups with similar buying behaviour. Nobody named the groups beforehand, the model only finds what belongs together in the data. Supervised answers a question that was asked, unsupervised discovers which questions could be asked at all.
What the model really can do
After training, everything learned sits entirely in the parameters, a long list of numbers. The model understands nothing, it has no idea what a cat is. It has merely found numbers that make its formula rarely wrong on the training examples. That works surprisingly well as long as new inputs resemble the training examples. On inputs unlike anything in training, the model can be arbitrarily wrong, and without any sign of uncertainty. Knowing this lets you use the strengths and plan around the weaknesses.
Exercises
0 of 6 solvedTime to try it yourself. You can't break anything, every attempt counts.
What happens when a model is trained?
A model is supposed to sort a thousand photos without any labels into similar groups. What kind of learning is that?
A model sorts 40 images and makes the right call on 32 of them. On how many images is it wrong?
Match each term with its description.
Out of 40 images, 8 are sorted incorrectly. What is the error rate in percent?
Put one training round in the correct order.
- 1Each knob is turned a small step toward fewer errors
- 2On the next example the model is a little closer to the answer
- 3The difference from the correct answer is measured as the error
- 4The model makes a prediction
Where this leads