Introduction: The Dream of a Machine That Learns
Imagine: you need to filter 10,000 emails a day to catch spam. You could write rules: "If the subject contains URGENT AND make money, it's spam." But spammers adapt quickly. Tomorrow, they'll use different words. You'll spend your life writing rules that don't work.
Now imagine an alternative: you show 1 million emails to a system and tell it "this one is spam, this one isn't." Without writing a single rule, the system learns to recognize regularities. A new spam arrives? The system adapts. That is Machine Learning, usually shortened to ML.
Machine Learning is about letting the data speak for itself. Instead of writing rules by hand, you provide examples and the algorithm discovers the rules on its own. The more examples you give it, the better it gets.
Tom Mitchell, in 1997, put it more formally: a system learns from experience E on a task T with a performance measure P, if P improves with E. In plain English: the more examples you show me (E), the better I do the job (T), and you can measure it (P).

Traditional Programming vs Machine Learning
Traditional Approach: The Rule-Coding Developer
You're a developer. You need to detect spam. You start writing:
- If the subject contains "URGENT" AND "make money" -> spam
- If the sender is unknown AND more than 3 links -> spam
- If it's signed by a bank but the address looks sketchy -> spam
It works... for 2 months. Then spammers change their tactics. They stop using "URGENT." Now they use "IMPORTANT!!!" You need to write a new rule. And another one. And another one. It's an endless race: you're chasing the spammers, but you never catch up.
Machine Learning Approach: The Automatic Learner
Different approach: you give 100,000 emails to the system. "Here are 50,000 spam, 50,000 legitimate." The system looks at patterns: common words in spam, structures, length, suspicious senders, sketchy links... It learns. A new spam arrives with a never-before-seen tactic? If it resembles what it's seen (even loosely), it recognizes it.
The system adapts without you rewriting the code. These aren't hard-coded rules: they're learned patterns.
The Three Main Types of Learning
Just as there are several ways to learn (with a teacher, by exploring on your own, through trial and error with rewards), ML has three major "schools."

1. Supervised Learning: Learning with a Teacher
This is the most common one. You show pairs: "Here's an image of a cat. It's a cat." "Here's a price for this apartment: $420,000." The model learns to predict: "For an image that looks like this, it's a cat." "For an apartment with this area and this neighborhood, the price is around $400,000."
Concrete Examples:
- Apartment prices: you show 10,000 sold apartments + their prices. The model learns the relationship.
- Recognizing cats in photos: 100,000 photos labeled "cat," 100,000 labeled "not cat."
- Banking fraud: 10 million transactions: 99.9% legitimate, 0.1% fraud. The model learns to spot suspicious transactions even among an immense majority of normal ones.
It's exactly like school. The teacher shows you the answers (labeled data). You study them. Then you take the exam (new data) without the answers. If you've understood the patterns well, you pass.

2. Unsupervised Learning: Learning by Exploring
No teacher here. No labels. Just raw data. "Here are 100,000 customers. Organize them into groups. Figure it out."
It's as if you arrived in an unknown city with no map, no one to tell you where to go. You explore and notice patterns: people live near the center, there are wealthier neighborhoods, poorer ones. You create your own categories.
Concrete Examples:
- E-commerce: 1 million customers. The model finds: "customers who buy often in small amounts," "occasional customers who spend big," "visitors who never take the plunge." Each group receives a different marketing strategy.
- Images: show 1 million photos without labels. The model learns: "these photos are visually similar," "these groups are totally different."
- Detecting outages: 1,000 servers, 10 years of logs. Detects anomalies: "this server is doing something weird, even if we don't have a 'failure' label."

3. Reinforcement Learning: Learning by Trial and Error
A robot or agent learns by doing. It tries an action. If it works, it receives a reward. If it fails, a penalty. It learns to maximize the cumulative reward over time.
It's like a child learning to walk: nobody tells them "contract muscle A then B then C." The child falls (penalty), succeeds in taking a step (reward), and learns through repetition.
Concrete Examples:
- AlphaGo plays Go. With each move, it receives a reward (win) or a penalty (loss). By playing millions of games, it discovers the best strategy.
- A robot learning to grasp an object: "Great, you grabbed it! +10 points." "Oops, you dropped it. -5 points."
- ChatGPT: the model generates text. Humans say "I like this answer" or "this one is terrible." The model learns to generate what humans prefer (this is RLHF, reinforcement learning from human feedback, see RLHF).

A Brief History of Machine Learning
ML wasn't born yesterday. Here are the major milestones that led to the current revolution.

The Origins (1950-1980)
- 1943: McCulloch and Pitts propose the first mathematical model of an artificial neuron.
- 1957: Frank Rosenblatt invents the perceptron, one of the first learning algorithms.
- 1969: Minsky and Papert publish Perceptrons, showing the limitations of the simple perceptron: it cannot learn the exclusive-or function (XOR, true when exactly one of the two inputs is true), which is about as elementary as a rule gets. This triggers the first "AI winter", a long stretch of lost interest and lost funding.

Renaissance and Foundations (1980-2000)
- 1986: Rumelhart, Hinton, and Williams popularize backpropagation, enabling the training of multi-layer neural networks.
- 1995: Vapnik introduces Support Vector Machines (SVM), which dominate the field for a decade.
- 1997: Deep Blue (IBM) beats Garry Kasparov at chess by systematically enumerating possible moves and scoring each resulting position with approximate hand-written rules.


The Deep Learning Era (2006-present)
- 2006: Geoffrey Hinton shows how to pre-train deep networks layer by layer.
- 2012: AlexNet wins the ImageNet competition by a considerable margin, launching the deep learning revolution.
- 2017: The paper "Attention Is All You Need" introduces the Transformer architecture, which becomes the foundation of modern LLMs.
- 2022-2024: Large Language Models (LLM) (GPT-4, Claude, Llama, Mistral) democratize generative AI.

Why is ML Exploding Now?
Three factors converge to explain the recent explosion of Machine Learning:
1. Massive Data
The internet, smartphones, connected devices, and social media generate amounts of data with no historical precedent. Published estimates of the daily worldwide volume disagree by a factor of ten depending on what gets counted, so we will quote none of them. What matters for the rest of the course is simpler: ML needs examples to learn from, and the stock of available examples has changed scale.
2. Accessible Computing Power
Graphics Processing Units (GPU), initially designed for gaming, turned out to be perfectly suited to ML arithmetic: it is mostly multiplication of large tables of numbers, and a GPU does thousands of those at once where an ordinary processor does them nearly one at a time. NVIDIA has transformed its business around AI computing. Renting machines remotely (cloud computing, at Amazon, Google, Microsoft) made that power available without buying the hardware.

3. More Powerful Algorithms
Theoretical advances (transformers, attention, better optimization methods) have made it possible to build more powerful and efficient models. The open-source community (Hugging Face, PyTorch, TensorFlow) has democratized access to these tools.
Data + Compute + Algorithms = the recipe for modern ML success. The absence of any one of these three ingredients was the main bottleneck in previous decades.
Essential Vocabulary
These eight words come back throughout the rest of the course. Take them seriously once and everything after flows.
One image holds them all: an espresso machine with dials. Grind, pressure, temperature. You tune it by tasting the coffee and correcting.
- Model: the machine itself, a computation recipe turning an input (beans, or a photo, or a sentence) into an output (a cup, or a prediction). It is not a program written line by line; it is a fixed shape whose settings remain to be found.
- Parameter: one dial. A number living inside the model that training will move. A recent language model has billions of them. They are also called weights.
- Training: the stretch of time during which the dials get turned. Show an example, look at what comes out, correct. Millions of times over. During training the parameters move; afterwards they are frozen. That is the single most useful distinction in the field: in any formula, always know which letters are learned parameters (frozen in use) and which letters are values recomputed every time.
- Loss: the mark you give the coffee. One number saying how bad the output is. Large loss = far from the right answer. All of training is pushing that number down.
- Gradient: for each dial, the answer to "if I turn it one notch clockwise, does the mark get better or worse, and by how much?". A direction with a size attached. Computing all those answers has a name, backpropagation, covered in Backpropagation.
- Inference: using the tuned machine to actually make coffee. The model predicts; the parameters no longer move.
- Overfitting: the machine has been tuned so finely to the 200 cups used during setup that it can do nothing else. It memorized instead of learning the rule. Its mirror image, underfitting, is a machine too coarse to catch any nuance at all.
- Validation: the second taster. A batch of cups set aside, on which you never tune anything, purely to check the machine works somewhere other than on its own examples. Without it you have no way to spot overfitting.
Two plainer words to finish: features are the input variables describing a case (area, age, color), the label is the correct answer supplied with the example, and the dataset is the whole collection of examples.
Real-World ML Applications Today
ML is everywhere, often invisibly:
- Healthcare: early cancer detection on medical images, pandemic prediction, drug discovery.
- Finance: fraud detection, algorithmic trading, credit scoring.
- Transportation: autonomous vehicles, route optimization, traffic prediction.
- Commerce: product recommendations (Netflix, Spotify, Amazon), price optimization.
- Language: machine translation, conversational assistants, text generation.
- Science: protein structure prediction (AlphaFold), climate simulation.

What ML Can't Do (Yet)
It's important to keep a critical eye. Current ML has its limitations:
- Causal reasoning: models find correlations, not causes. They see that two things move together, not that one produces the other.
- Out-of-distribution generalization: a model trained on certain data can fail when faced with very different situations.
- Explainability: deep models are often "black boxes" that are hard to interpret.
- Common sense: despite the progress of LLMs, common-sense reasoning remains a challenge.
An ML model is only as good (or bad) as the data it's trained on. Biased data produces biased models. This is a major ethical issue in AI.

Going Further
In the upcoming sections, we'll dive deeper into each of the three types of learning: supervised, unsupervised, and reinforcement learning. We'll then see how the perceptron, a simple supervised learning algorithm, lays the groundwork for the deep neural networks that power today's generative AI.
1. For spam filtering, what fundamentally separates classic programming from Machine Learning?
2. A system is given 1 million customers with no labels at all and asked to sort them into groups. Which type of learning is this?
3. A model is trained, then deployed to serve users (inference). What happens to its parameters during inference?
4. What is the validation set for?
5. An ML model trained on biased historical data will most likely…