Introduction & History
Machine Learning (ML) is the field of study that gives computers the ability to learn from data without being explicitly programmed for every situation. Instead of writing rules by hand, we write programs that infer the rules from examples.
This first lesson says what "learning" means, when it is worth it, and shows it at work in a machine with no electronics at all: matchboxes and colored beads that learn a small board game from feedback alone. It then tells how the field got here, in 200 years of history, and maps the questions the rest of the course will answer. The numbers quoted about the matchbox machine come from its two simulators on this page, which are deterministic: everyone who presses the same buttons sees the same games.
How this lesson is organized
The lesson has two approaches. Each has slides, text and an activity to do in class in the simulator on this page; the quiz at the end covers the fundamental one. Start with the fundamental approach: the advanced one builds on it.
| Fundamental approach | Advanced approach | |
|---|---|---|
| question | What does it mean for a machine to learn, and when is it worth it? | How did the field get here, and which questions will the rest of the course answer? |
| content | Mitchell's definition (task, experience, performance), when hand-written rules break down, the inverted flow, the matchbox machine that learns Hexapawn, the three forces behind today's ML and its main eras | the full timeline, from matchboxes to the perceptron, two AI winters and two revivals, three lessons from the arc, where this course fits and the questions it will answer |
| in-class lab | teach the matchbox machine, steps 1 to 3 | what the machine learned, and the map of the course, steps 4 to 6 |
| by the end, you can | describe any learning system by its \(T\), \(E\) and \(P\); tell when to learn rather than program; explain learning as adjusting parameters from feedback; name the three forces behind today's ML | place a method on the timeline; explain why a model that generalizes beats a lookup table; recognize a hype cycle and its antidote; take a modern method apart into classical pieces |
Both labs run in the matchbox simulator of section 3, in the browser: there is nothing to install, and no notebook this time.
Fundamental approach
One question drives this part: what does it mean for a machine to learn, and when is it worth it? The answer starts from a definition with three ingredients, a task, experience and a way to measure performance, and ends with a machine made of matchboxes that gets better at a game only because its mistakes are removed, one bead at a time.
This part follows one path in four stages, drawn below: 1. what learning is, Mitchell's definition; 2. why learn, when hand-written rules break down and how learning inverts the flow; 3. a machine that learns, matchboxes that learn a game from feedback alone; 4. why now, the three forces behind today's machine learning and its main eras. Each stage links to its section, and in the slides a strip at the bottom shows which stage you are in.
- 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
Fundamental approach slides
Click the slides and use the β β arrows to navigate; F opens full screen and Esc shows every slide. Open the slides in a new tab
1. What it means to learn
Stage 1. The classic formal definition is due to Tom Mitchell:
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 that vocabulary. A spam filter, for instance:
- 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 of e-mails classified correctly (or a more careful metric, as we will see in Classification Metrics).
The three ingredients are not optional. Without \(P\) there is no way to say that anything improved, and a system that only stores more and more examples, with no measure of whether it answers better, has not learned in Mitchell's sense.
2. Why learn from data?
Stage 2. Hand-written rules break down when:
- The rules are unknown. Nobody can write down the exact rules that distinguish a malignant tumor from a benign one in a raw image.
- The rules change. Spammers adapt; a static filter decays. A learning system can be retrained.
- The rules are too many. Recognizing handwritten digits with
if/elsestatements is hopeless β there are too many ways to write a "7". - Personalization is needed. A recommender must behave differently for every user; learning from each user's history scales, hand-tuning does not.
Machine learning inverts the traditional flow: instead of rules + data β answers, we feed data + answers to an algorithm and obtain a model β an approximation of the rules β which we then use to answer new, unseen cases.
The converse matters as much: when the rule is fixed, fully known and short, such as "a card number has exactly 16 digits", program it. Learning pays off only where one of the four reasons above holds.
3. A learning machine made of matchboxes
Stage 3. Long before GPUs, Martin Gardner's 1962 Scientific American column described a machine that learns to play a game using only matchboxes and colored beads β no electronics at all. For the mini-game Hexapawn (three pawns per side on a 3Γ3 board), build one matchbox per possible board position, and fill it with beads for each legal move:
- to move, open the matchbox for the current position and draw a random bead β that's the move;
- if the machine eventually loses the game, remove the bead that led to the losing move (punishment);
- if it wins, the beads stay (or extra copies are added β reward).
If the box for the current position is empty, every move from there has already lost: the machine resigns, and the punishment goes to the move that led it there. After a few dozen games the bad moves have literally been removed from the boxes: the machine plays perfectly. This is reinforcement learning in its purest mechanical form (Donald Michie built the same idea for tic-tac-toe in 1961 and called it MENACE), and it makes Mitchell's definition tangible: the task \(T\) is playing Hexapawn, the experience \(E\) is games played, the performance \(P\) is the win rate β and learning is nothing more than adjusting parameters (beads) based on feedback.
The learning loop, step by step
The machine needs 19 boxes, one per position it can face when a position and its mirror image share a box, and 47 beads, one per legal move. The simulator below follows its first three training games against an opponent that plays at random, one move per step: the position, the box for that position, the bead drawn and, at the end of each game, the update. The panel on the right keeps Mitchell's tally, \(E\) games played and \(P\) the win rate.
Game 1 is lost and its last bead goes (47 β 46); game 2 is won and nothing changes, since this machine only punishes; game 3 is lost again (46 β 45), and the bead removed was the only one in its box, so that box is now empty. After three games \(P = 1/3\): learning has barely started, but every loss already makes one bad move impossible.
Play against the machine
Play against the machine below (you are blue and move first), then press train N games and watch the beads disappear from the boxes as the machine's win rate climbs. Keep an eye on the line under the simulator: at some point the machine can no longer be beaten.
Nothing in the boxes "understands" Hexapawn: the machine got better only because feedback removed the moves that lost.
Read the original
Gardner, M. (1962). How to build a game-learning machine and then teach it to play and to win. Scientific American β PDF. We play this game in the first class.
4. Why now?
Stage 4. None of the core ideas are new β least squares is from 1805 β but three forces converged in the last two decades to make ML ubiquitous:
- Data: the web, sensors, and digitization produced datasets large enough to learn subtle patterns;
- Compute: GPUs and cloud computing made it cheap to fit large models;
- Algorithms & software: open-source libraries (scikit-learn, XGBoost, PyTorch) turned decades of research into a few lines of code.
The main eras
The history of ML is a 200-year conversation between statistics and computer science. In five eras (the advanced approach tells it milestone by milestone):
| era | when | what happened |
|---|---|---|
| statistics lays the ground | 1805β1936 | Legendre publishes least squares (1805), to fit the orbits of comets; Galton names regression (1886); Fisher builds maximum likelihood and discriminant analysis |
| the first learning machines | 1950β1962 | Turing asks whether machines can think (1950); Rosenblatt's perceptron (1958) and Samuel's checkers program (1959) learn from examples; Michie's MENACE (1961) and Gardner's matchboxes (1962) learn from feedback |
| two AI winters | 1969β1993 | promises outran results and funding was cut, roughly in 1974β1980 and in 1987β1993; in between, backpropagation and decision trees revive learning |
| statistical learning | 1995β2001 | support vector machines, boosting and random forests: rigorous theory and honest validation |
| deep learning and foundation models | 2012βtoday | deep networks trained on GPUs (2012), transformers (2017), one giant pre-trained model for many tasks (2020βtoday) |
The last era is where the three forces meet: deep networks are an idea of the 1980s that needed the data and the compute of the 2010s.
5. Summary: learning in five lines
- ML is programs that infer the rules from examples, instead of rules written by hand.
- Learning, after Mitchell: performance \(P\) on a task \(T\) improves with experience \(E\). No \(P\), no learning.
- It inverts the flow: data + answers β model, used on new, unseen cases. It pays off when the rules are unknown, change, are too many or must be personalized; a short, fixed rule should be programmed.
- The matchbox machine: learning is adjusting parameters (beads) from feedback (losses), with no understanding at all.
- Why now: the ideas are old; data, compute and open-source software made them practical.
Fundamental lab β teach the matchbox machine
The problem. A fresh matchbox machine plays Hexapawn at random. You will play against it, train it and try to beat it after training, watching \(E\) grow, \(P\) climb and the beads go. The question behind the three steps: when can you say that a machine has learned, and how sure can you be that it has learned everything?
How to do this lab in class (about 25 min, in pairs)
- Use the matchbox simulator of section 3, in the browser: nothing to download or install. If you have Gardner's printed boards and beads, play the first games on paper, one of you being the machine.
- This lab is steps 1 to 3. The advanced lab continues in the same simulator, from step 4.
- Every step starts with a Predict: answer it with your partner before pressing any button. Getting the prediction wrong is what makes the result memorable.
- The simulator is deterministic after reset machine: the same buttons give the same games, so your output should match the one on this page exactly.
- The Simulations ask you to run a small experiment in the simulator: change one thing and watch what happens. No hand calculations. The solution is collapsed right below: try before opening it.
- Suggested pace: step 1 in 7 min; step 2 in 6 min; step 3 and the two simulations in 12 min.
Step 1 β play a fresh machine
Predict. A fresh machine draws its moves at random from full boxes. Will you beat it easily? And when you win, what changes inside its boxes?
Before playing, step through the learning loop once (about 20 clicks). Then play three games against the machine: click one of your blue pawns, then its destination square. After each game, look at the boxes: the box the machine used last has an orange border, and the bead of its last move is ringed.
A fresh machine is easy to beat, and every win of yours removes one bead, marked β in its box: that move will never be played again. When the machine wins, its beads stay where they are. The line under the board counts the beads left, out of 47.
Step 2 β train it for 50 games
Predict. Press reset machine (opponent: random, N = 50) and then train N games. Will the win rate climb smoothly? Will the machine stop losing within these 50 games?
The readout under the simulator says:
50 games played: the machine won 36 and lost 14; each loss removed one bead. Beads left: 33/47.
Can it still be beaten? yes: some line of play still leads to a bead that loses.
The 14 losses removed 14 beads (47 β 33). They are not spread evenly: the red marks on the curve crowd at the left, and all 14 losses happen in the first 38 games (games 1, 3, 5, 6, 7, 8, 9, 11, 19, 20, 21, 27, 30 and 38). The win rate over the last 10 games does not climb smoothly, because the machine still draws at random among the beads it has left. In Mitchell's terms: \(E\) grew from 0 to 50 games and \(P\) rose from losing 8 of the first 11 games to winning the last 12 in a row.
Step 3 β the champion that can still be beaten
Predict. Train 50 more games (same N). If the machine wins all 50, can you conclude that it can no longer be beaten?
50 games played: the machine won 50 and lost 0; each loss removed one bead. Beads left: 33/47. It won every game, yet it can still be beaten: it only learned the lines this opponent plays.
Can it still be beaten? yes: some line of play still leads to a bead that loses.
Fifty wins in a row, and still beatable. A random opponent rarely plays the one line that still works, so no game in this batch reached the losing bead, and a bead that is never reached is never punished. A perfect record on the games it has seen says nothing about the games it has not.
Simulation: beat the champion. Without training any further, play against the machine yourself and find a line of play that still beats it. Hint: open with your center pawn, and think about which pawn of yours can reach the last row once the machine captures.
Solution
Move your center pawn forward (b1 β b2). The machine captures it with a corner pawn, say a3 β b2. Push your pawn on the same side as the capture, a1 β a2. In that position the machine's box has 4 beads: two win at once (b2 β b1 and b2 β c1), one captures your pawn (b3 β a2) and one, c3 β c2, loses, because your pawn then reaches the last row (a2 β a3). The mirror line works the same way (if it captures from c3, push c1 β c2).
The machine draws that bead with chance 1 in 4, so you may need a few games; losing costs you nothing, since the machine never changes when it wins. When you do win, the bead c3 β c2 is removed and the readout becomes:
Can it still be beaten? no: whatever blue plays, every bead left leads to a win. Learning = beads removed by feedback.
with 32 beads left: your single win taught it the last lesson it was missing.
Simulation: let the random opponent find it. Press reset machine, train 50 games twice (as in steps 2 and 3), then set N = 200 and train twice more. In which batch does the 15th loss come, and what does the readout say after it?
Solution
200 games played: the machine won 200 and lost 0; each loss removed one bead. Beads left: 33/47. It won every game, yet it can still be beaten: it only learned the lines this opponent plays.
200 games played: the machine won 199 and lost 1; each loss removed one bead. Beads left: 32/47.
Can it still be beaten? no: whatever blue plays, every bead left leads to a win. Learning = beads removed by feedback.
Games 101 to 300 bring no loss at all. The 15th and last loss comes at game 334: the random opponent finally plays the line of the previous simulation, the bead c3 β c2 goes, and the machine is unbeatable with 32 beads. It took 296 games after the 14th loss (game 38) for the data to contain that one rare line. Rare cases take a long time to show up in the experience \(E\), and until they do, nothing can be learned from them.
To close the fundamental part. In one sentence each: (1) what are \(T\), \(E\) and \(P\) for the matchbox machine? (2) What, exactly, changed inside the machine when it got better? (3) Why did 50 wins in a row not prove that it could no longer be beaten?
Your turn (fundamental)
At home:
- Mitchell's vocabulary. Describe three systems you use every day (a recommender, a voice assistant, a map that predicts traffic, for instance) by their \(T\), \(E\) and \(P\). Which one is hardest to give a \(P\)?
- Learn or program? For each of the four reasons hand-written rules break down, find an example from your own experience; then find one task you would simply program.
- On paper. Read Gardner's original article and play Hexapawn with a friend, one of you being the machine with boxes and beads. How many games does your machine need before it stops losing?
Advanced approach
The fundamental part defined learning and watched a machine do it. This part steps back to see how the field got here and where this course is going: the 200-year timeline, what the matchbox machine has in common with the perceptron (and what it lacks), the two AI winters and the revivals that followed, three lessons that shape the design of this course, and the questions the next lessons will answer.
This part follows one path in four stages, drawn below: 1. 200 years of milestones; 2. the perceptron and the winters; 3. reading the arc; 4. the course ahead. Each stage links to its section, and in the slides a strip at the bottom shows which stage you are in.
- 200 years of milestonesstatistics and computer science
- The perceptron and the wintersa table of boxes vs. a model; hype and revivals
- Reading the arcthree lessons for this course
- The course aheadclassical ML end to end, up to the frontier
Advanced approach slides
Click the slides and use the β β arrows to navigate; F opens full screen and Esc shows every slide. Open the slides in a new tab
6. A brief history of machine learning
Stage 1. The history of ML is a 200-year conversation between statistics and computer science. The timeline below marks the milestones this course will visit β from the historical basis to the current edge.
[timeline left alternate(./docs/2026.2/classes/introduction/timeline.json)]
7. From matchboxes to the perceptron, and two winters
Stage 2. The matchbox machine and Rosenblatt's perceptron (1958) learn the same way: from feedback on their mistakes. The perceptron is a linear classifier with one weight per feature; when it gets an example wrong, it nudges its weights toward the right answer, and when it gets it right, it changes nothing β the neural networks lesson runs it by hand. The difference is in what is stored. The matchbox machine keeps one box per position, a lookup table: what it learns in one box says nothing about any other, and a position it never met would find no box at all. The perceptron keeps a few weights shared by every input, so each update changes its answer on examples it has never seen: it generalizes. Hexapawn is small enough to give each of its positions a box; almost no real problem is, which is why every model in this course is a function with parameters, not a table of answers.
That generalization has limits, and the first one stopped the field. In 1969 Minsky and Papert proved that a single perceptron cannot learn problems that are not linearly separable, such as XOR; the Lighthill Report (1973) concluded that AI had failed to deliver, and funding collapsed across the US and the UK: the first AI winter (roughly 1974β1980). Learning revived in the 1980s on two fronts: backpropagation (1986) made multi-layer networks trainable β and they do solve XOR β while CART (1984) and ID3 (1986) made decision trees practical. A second winter (roughly 1987β1993) followed the collapse of the expert-systems boom, programs built from hand-written rules β exactly the approach that section 2 says breaks down. Both winters have the same shape: promises outran results.
Two revivals followed, each answering a weakness. Statistical learning (1995β2001: support vector machines, AdaBoost, random forests, gradient boosting) brought theory β margins, generalization bounds β and the habit of honest validation. Deep learning (2012 onward) brought neural networks back at scale, once the three forces of section 4 were in place: large labeled datasets, GPUs and open software.
8. Reading the arc
Stage 3. Three lessons from this history shape the design of this course:
- The classics never left. Least squares (1805) is still the first model you should try on a regression problem. Logistic regression (1958) remains a production workhorse. Understanding them deeply is not archaeology β it is engineering.
- Hype cycles are real. The field went through two "AI winters" (roughly 1974β1980 and 1987β1993) when promises outran results. Honest evaluation β the subject of the cross-validation lesson β is the antidote.
- Modern methods are compositions of classical ideas. BERTopic (2022), which we will study in its own lesson, is literally a pipeline of embeddings + dimensionality reduction + clustering + TF-IDF β every ingredient is a classical technique. Gradient boosting is functional gradient descent on decision trees. Knowing the parts lets you understand β and debug β the whole.
9. Where this course fits
Stage 4. This course covers classical machine learning end to end and finishes at the frontier: neural networks, explainability, AutoML, MLOps, and foundation models. Deep learning gets one bridging lecture here; its full treatment lives in the companion course Artificial Neural Networks and Deep Learning.
The questions the course will answer
Every lesson ahead answers one question that a real project raises sooner or later:
| question | where the course answers it |
|---|---|
| What kinds of learning are there, and will a model work on cases it never saw? | The ML landscape |
| What does the data look like, and is it ready for a model? | Exploratory data analysis, preprocessing, pipelines |
| Is there structure in the data with no labels at all? | Dimensionality reduction, clustering |
| How do we predict a number? | Linear regression, gradient descent and regularization |
| How do we predict a class? | Logistic regression, k-NN, SVM, decision trees, random forest, gradient boosting |
| How good is the model, really? | Classification metrics, ROC, PR and imbalanced data, cross-validation |
| Which model, with which settings? | Model selection |
| Why did the model decide that, and how does it run in production? | Explainability, MLOps |
Advanced lab β what the machine learned, and the map of the course
The fundamental lab trained the machine against a random opponent until it could not be beaten. This part asks what the machine really learned β the game, or the opponent it trained against β and then turns from the matchboxes to the map: where each milestone of the timeline lives in this course, and which classical pieces a modern method is made of.
How to do this lab in class (about 25 min, in pairs)
- Step 4 uses the matchbox simulator of section 3; steps 5 and 6 use the timeline of section 6 and the table of questions of section 9.
- As in the fundamental lab: Predict before acting, compare with this page, and try the Simulation before opening the solution.
- Suggested pace: step 4 and the simulation in 10 min; step 5 in 8 min; step 6 in 7 min.
Step 4 β a different teacher
Predict. The greedy opponent wins at once when it can, otherwise captures, otherwise plays at random: a stronger player than the random one. Will a machine trained against it be stronger against everyone?
Press reset machine, click the opponent button until it reads opponent: greedy, set N = 200 and train twice:
200 games played: the machine won 193 and lost 7; each loss removed one bead. Beads left: 40/47.
Can it still be beaten? yes: some line of play still leads to a bead that loses.
200 games played: the machine won 200 and lost 0; each loss removed one bead. Beads left: 40/47. It won every game, yet it can still be beaten: it only learned the lines this opponent plays.
Can it still be beaten? yes: some line of play still leads to a bead that loses.
The greedy opponent teaches fast β 7 losses, all within the first 27 games β but it teaches less. It never passes up a win or a capture, so the lines in which blue declines a capture never happen, and the beads on those lines are never punished: after 400 games the machine keeps 40 beads, against the 32 of the machine that became unbeatable against the random opponent, and it can still be beaten. The machine learned to beat this opponent, not the game. A model learns the distribution of its experience \(E\); if the cases it will face later come from a different distribution, its performance \(P\) on the training games says little about them. This is the central problem of the ML landscape lesson, generalization.
Simulation: change the teacher. Without resetting, switch the opponent back to random and train 200 more games. Does the machine lose again? Does it become unbeatable?
Solution
200 games played: the machine won 197 and lost 3; each loss removed one bead. Beads left: 37/47.
Can it still be beaten? no: whatever blue plays, every bead left leads to a win. Learning = beads removed by feedback.
The champion against the greedy opponent loses 3 of its first 200 games against the random one (games 10, 31 and 156 of this batch): new kinds of experience expose new mistakes. After those 3 punishments it is unbeatable, with 37 beads left, while the machine trained only against the random opponent ended with 32: both are unbeatable, yet different beads were removed along the way. Two teachers, two different machines for the same game: the experience \(E\) shapes the model as much as the learning rule does.
Step 5 β the timeline as a map of the course
Predict. Which milestones of the timeline do you expect to meet again in this course, and which are history only?
For each milestone of the timeline, name the lesson of this course that teaches the method it introduced, using the table of questions and the course menu.
Solution
| milestone | lesson |
|---|---|
| least squares (1805) | linear regression |
| regression to the mean (1886) | model selection |
| logistic regression (1958, in section 8) | logistic regression |
| the perceptron (1958), backpropagation (1986) | neural networks |
| CART (1984) and ID3 (1986) | decision trees |
| support vector machines (1995) | SVM |
| AdaBoost (1997) and gradient boosting (2001) | gradient boosting |
| random forests (2001) | random forest |
| word2vec (2013) | word embeddings |
| transformers and BERT (2017β2018) | sentence embeddings, BERTopic |
| foundation models (2020βtoday) | the frontier |
| the AI winters, and honest evaluation as their antidote | cross-validation |
Almost every milestone is a lesson: the course is, roughly, the timeline in teaching order. The exceptions are the ideas that are context rather than method (Turing's question, the Dartmouth workshop), and Fisher's foundations, which run under several lessons at once (maximum likelihood is how logistic regression is fitted).
Step 6 β take a modern method apart
Predict. Gradient boosting and random forests dominate tabular data today. Are they new ideas, or old ones put together?
Write each method below as a sum of pieces from the timeline, and name the lesson where each piece is taught: (a) random forest; (b) gradient boosting; (c) BERTopic.
Solution
- Random forest = decision trees (CART, 1984) + bootstrap resamples + a vote, with a random subset of the features at each split. The decision trees lesson builds the vote of 100 trees by hand; the random forest lesson adds the random features.
- Gradient boosting = decision trees + gradient descent: functional gradient descent on decision trees, each new tree fitted to the errors of the sum so far (gradient descent, gradient boosting).
- BERTopic = sentence embeddings + dimensionality reduction + clustering + TF-IDF (sentence embeddings, dimensionality reduction, clustering, TF-IDF).
The third lesson of section 8, in practice: knowing the parts is what lets you understand β and debug β the whole.
To close the lesson. In one sentence each: (1) why does a model that generalizes beat a table of boxes, one per case? (2) What do the two AI winters have in common, and what is their antidote? (3) Why did the machine trained against the greedy opponent remain beatable?
Your turn (advanced)
At home, with more time:
- Reward, not only punishment. Gardner's rule also allows a reward: when the machine wins, add an extra copy of each bead it used. Predict what would change: would the machine stop losing sooner, later, or after the same number of losses? And would it still be beatable after a long winning streak against the random opponent?
- A bigger board. MENACE learned tic-tac-toe with the same idea. Why does tic-tac-toe need many more boxes than Hexapawn, and what would happen to a matchbox machine for chess? Relate your answer to the difference between a lookup table and a model that generalizes (section 7).
- A hype check. Pick a recent news story about an AI system. Describe it by its \(T\), \(E\) and \(P\), and write down the one piece of honest evaluation you would ask for before believing the claim.
References
- Turing, A. M. "Computing Machinery and Intelligence." Mind 59 (1950). DOI
- Samuel, A. L. "Some Studies in Machine Learning Using the Game of Checkers." IBM J. Res. Dev. 3 (1959). DOI
- Bishop, C. M. Pattern Recognition and Machine Learning. Springer, 2006.
Quiz
The quiz covers the fundamental approach.