What Is Machine Learning?
Here is the oldest way to make Bolt smart: an engineer sits down and writes rules. If it's raining and the order is from Hostel C, take the covered walkway. This works until it doesn't. There are too many situations, the rules contradict each other, and the campus changes every semester.
Machine learning flips the process. Instead of writing the program, we write a program that writes the program from examples.
Tom Mitchell's definition (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.
For Bolt's delivery-time predictor: T = predict how many minutes a delivery takes, P = average squared error in minutes², E = a log of past deliveries. If the predictions get more accurate as the log grows, Bolt is learning.
Notice that P, the performance measure, appears again. It is the same idea as the agent's performance measure in §1.1. In ML it is usually called a loss (lower is better) or a reward/utility (higher is better). Chapter 2 is about choosing and minimizing a loss. Chapters 4–5 are about maximizing a utility. Same coin, two sides.
The three main kinds of learning
| Type | What you're given | What you learn | Bolt example | In this course |
|---|---|---|---|---|
| Supervised | Inputs with correct answers \((x, y)\) | A function \(h(x) \approx y\) | Predict delivery time from distance; predict "late?" from weather | Ch 2, Ch 6 |
| Unsupervised | Inputs only \(x\) | Structure: clusters, densities, a compressed representation | Group hostels into zones with similar order patterns | (touched on in Ch 7: learning distributions) |
| Reinforcement | States, actions and occasional rewards | A policy: which action to take in each state | Learn routes from "+10 for a fast delivery, −50 for a crash" | Foundations: MDPs in Ch 5 |
Supervised learning splits further by the type of \(y\):
- Regression: \(y\) is a number (delivery time = 13.4 minutes).
- Classification: \(y\) is a category (late / on time; spam / not spam).
The vocabulary you'll use every day
| Term | Meaning | Bolt |
|---|---|---|
| Example / instance / sample | One data point | One past delivery |
| Feature / attribute \(x\) | A measured input | distance, rain (yes/no), hour of day |
| Label / target \(y\) | The answer we want to predict | minutes taken |
| Hypothesis / model \(h\) | A candidate function from \(x\) to \(y\) | \(h(x) = 3 + 4.2\cdot\text{distance}\) |
| Hypothesis space \(\mathcal{H}\) | The set of all models we're willing to consider | all straight lines; all degree-5 polynomials; all decision trees |
| Parameters / weights \(w\) | The numbers that pick one \(h\) out of \(\mathcal{H}\) | the 3 and the 4.2 above |
| Hyperparameters | Settings chosen before training that shape \(\mathcal{H}\) or the training process | polynomial degree, tree depth, GA mutation rate |
| Loss \(L\) | How wrong a prediction is | \((h(x)-y)^2\) |
Once you pick a hypothesis space \(\mathcal{H}\) and a loss, "learning" means searching \(\mathcal{H}\) for the \(h\) with the lowest loss. Sometimes the search is a formula (least squares, §2.1). Sometimes it is gradient descent. Sometimes there is no gradient and you use hill climbing or a genetic algorithm (Ch 3). Sometimes it is a greedy recursive split (ID3, Ch 6). Keep "learning is search" in mind. It is the thread that ties Chapter 2 to Chapter 3.
The ML workflow, end to end
Every practical ML project, including every assignment in this course, follows roughly this pipeline:
- Define the problem. What are T, P and E? What does success look like as a number?
- Collect and understand data. Plot it. Look for missing values, outliers and leaks.
- Split the data into training, validation and test sets before doing anything clever (§2.4 explains why this is sacred).
- Choose a hypothesis space and a loss. Start simple: a line, a shallow tree.
- Train: search for the parameters that minimize training loss.
- Validate: measure error on data the model hasn't seen. Tune hyperparameters.
- Test once on the held-out test set and report that number honestly.
- Deploy and monitor. The world drifts (new hostel, new semester), so keep checking.
The fundamental problem: generalization
This is the most important paragraph in the chapter. Pay attention.
Bolt doesn't care about predicting last week's deliveries. Those already happened! It cares about tomorrow's deliveries, which it has never seen. So the real goal of learning is not to minimize error on the training data. The goal is to minimize error on new data from the same source. This is called generalization.
The trap: if you let the model be flexible enough, it can drive training error to zero by memorizing every example, noise included, and then fail badly on new data. This is overfitting, and avoiding it is the central drama of Chapter 2.
"My model has 100% training accuracy, so it's perfect." No. Training accuracy is a measure of memory, not intelligence. A lookup table has 100% training accuracy. Always ask: what is the error on data the model never saw?
Why no single model wins: inductive bias
Here is a deep fact: learning is impossible without assumptions. Suppose you've seen Bolt's delivery times for distances 1, 2 and 3 km. What's the time for 4 km? Infinitely many functions pass through your three points and disagree at 4 km. To predict anything you must prefer some functions over others, for example "smooth ones" or "simple ones." That preference is the model's inductive bias.
- Linear regression assumes the relationship is a straight line.
- Decision trees (ID3) prefer short trees with informative splits near the root.
- Bayes nets assume certain conditional independencies.
The No Free Lunch theorem makes this formal: averaged over all possible problems, every learning algorithm performs the same. An algorithm only wins when its inductive bias matches the problem you actually have. Choosing that bias well is the art of ML. Chapter 2 gives you the tools (bias–variance and validation) to choose it scientifically.
The campus hands you a log of past deliveries: distance and minutes taken. The relationship is curved: short trips are dominated by waiting for the lift, and long trips slow down on the hill near the library. Should Bolt fit a line? A cubic? A degree-12 polynomial? Next chapter, you'll see that this innocent question contains the whole theory of generalization.