Machine Learning · Insper
Introduction & History
Fundamental approach
What it means for a machine to learn, when it is worth it, and a machine made of matchboxes that does it
Two ways to get a computer to decide
write the rules
a person thinks of every case and writes it as code
learn the rules
we write a program that infers the rules from examples
Machine Learning (ML): the field that gives computers the ability to learn from data without being explicitly programmed for every situation.
The path of this part
- What learning istask, experience, performance
- Why learnwhen rules break down; the inverted flow
- A machine that learnsmatchboxes and beads learn Hexapawn
- Why nowdata, compute, software; the main eras
Each stage answers one question: what does "learn" mean? → why not just write the rules? → what does learning look like with no computer at all? → if the ideas are old, why only now?
Stage 1 · what does "learn" mean?
What does "learn" mean? Mitchell (1997)
A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.
- Every project in this course can be described in this vocabulary.
- No \(P\), no learning: a system that only stores more examples, with no measure of whether it answers better, has not learned.
Example: a spam filter
Predict. What are the task, the experience and the performance measure of a spam filter?
task \(T\)
classify e-mails as spam or not spam
experience \(E\)
a corpus of e-mails already labeled by humans
performance \(P\)
the fraction classified correctly (or a more careful metric, in the lesson on classification metrics)
Stage 2 · why not just write the rules?
Why learn from data? When rules break down
1. the rules are unknown
nobody can write the exact rules that tell a malignant tumor from a benign one in a raw image
2. the rules change
spammers adapt; a static filter decays, a learning system can be retrained
3. the rules are too many
handwritten digits with if/else: there are too many ways to write a "7"
4. personalization is needed
a recommender must behave differently for every user; learning from each history scales
Machine learning inverts the flow
What the inversion gives us
traditional
rules + data → answers
machine learning
data + answers → model
The model is an approximation of the rules, and we use it to answer new, unseen cases.
The converse: a rule that is fixed, known and short ("a card number has exactly 16 digits") should simply be programmed.
Stage 3 · what does learning look like with no computer at all?
A learning machine made of matchboxes
- Martin Gardner, Scientific American, 1962. No electronics at all.
- The mini-game Hexapawn: three pawns per side on a 3×3 board.
- One matchbox per possible board position, filled with beads, one color per legal move.
Predict. With only boxes and beads, how could this machine get better at the game after each match?
The rules of the matchboxes
- To move: open the box for the current position and draw a random bead. That is the move.
- If the machine loses: remove the bead that led to the losing move (punishment).
- If it wins: the beads stay, or extra copies are added (reward).
An empty box means every move from there has lost: the machine resigns, and the punishment goes to the move before.
After a few dozen games the bad moves have literally been removed from the boxes: the machine plays perfectly.
The learning loop, step by step
Predict. 19 boxes, 47 beads, an opponent that plays at random. After three games, how many beads will be gone, and what will \(P\) be? Then step through the first three training games.
Simulator: the matchbox machine
Predict. Train it for 50 games against a random opponent. Will the win rate climb smoothly, and will it ever stop losing?
What the matchboxes teach
- Reinforcement learning in its purest mechanical form. Donald Michie built the same idea for tic-tac-toe in 1961: MENACE (Matchbox Educable Noughts And Crosses Engine).
Learning is nothing more than adjusting parameters (beads) based on feedback.
Stage 4 · if the ideas are old, why only now?
Why now?
Predict. Least squares is from 1805. If the core ideas are that old, why did ML become everywhere only in the last two decades?
data
the web, sensors and digitization produced datasets large enough to learn subtle patterns
compute
graphics processing units (GPUs) and cloud computing made it cheap to fit large models
algorithms & software
open-source libraries (scikit-learn, XGBoost, PyTorch): decades of research in a few lines
200 years in five eras
| era | when | what happened |
| statistics lays the ground | 1805–1936 | Legendre's least squares (1805), for comet orbits; Galton names regression; Fisher |
| the first learning machines | 1950–1962 | Turing's question; the perceptron (1958); Samuel's checkers; MENACE and the matchboxes |
| two winters of artificial intelligence (AI) | 1969–1993 | promises outran results, funding was cut; backpropagation and trees in between |
| statistical learning | 1995–2001 | support vector machines, boosting, random forests: theory and honest validation |
| deep learning, foundation models | 2012–today | deep networks on GPUs, transformers, one pre-trained model for many tasks |
The last era is where the three forces meet: an idea of the 1980s that needed the data and compute of the 2010s.
Summary
- ML: programs that infer the rules from examples.
- Mitchell: learning = performance \(P\) on task \(T\) improves with experience \(E\). No \(P\), no learning.
- It inverts the flow: data + answers → model; worth it when rules are unknown, change, are too many or personal.
- Matchboxes: learning is adjusting parameters from feedback.
- Why now: data, compute, open-source software.
Next: The ML Landscape, a map of the kinds of learning and of a real project.
Fundamental lab · about 25 min, in pairs
Teach the matchbox machine, steps 1 to 3
- In the matchbox simulator on the lesson page: nothing to install. Press reset machine first: the same buttons give the same games.
- Step 1: play a fresh machine. Step 2: train it for 50 games. Step 3: 50 more, the champion that can still be beaten.
- At every step, answer the Predict before pressing a button.
- Simulations: beat the champion and let the random opponent find it (step 3).
Pace: step 1 in 7 min; step 2 in 6 min; step 3 and the two simulations in 12 min.