Three learning methods examined the way this book examines everything else: as algorithms with approximation ratios, regret bounds, and convergence rates.
The newest chapter in the 4th edition, and its angle is what makes it worth reading. This is not a statistics or neural-networks treatment. It takes three learning problems and analyses them with the tools of Parts I to VI: clustering gets an approximation-ratio proof, multiplicative weights gets a regret bound proved by a potential function, and gradient descent gets a convergence rate. Chapter 1 said machine learning is for problems you cannot specify; this chapter shows that the resulting methods are still just algorithms, and still analysable.
| Paradigm | Input | Goal | Example here |
|---|---|---|---|
| Unsupervised | Unlabelled data | Find structure | Clustering |
| Online / adversarial | A sequence of predictions and outcomes | Do nearly as well as the best fixed choice | Multiplicative weights |
| Supervised | Labelled examples | Minimise a loss function | Gradient descent |
Partition n points into k groups so that points in a group are similar and points in different groups are not. Two standard objectives, and they behave differently:
| Objective | Minimise | Character |
|---|---|---|
| k-means | Sum of squared distances to the nearest center | Optimises the average; sensitive to outliers |
| k-center | The maximum distance from any point to its center | Optimises the worst case; every point is covered |
| k-median | Sum of distances (not squared) | More robust to outliers than k-means |
k = 2 in general metric spaces. So the algorithms below are heuristics or approximations, never exact solvers — exactly the situation Chapter 35 is about.LLOYD'S ALGORITHM (the k-means algorithm)
1. Choose k initial centers.
2. repeat
assign each point to its nearest center
recompute each center as the centroid of its assigned points
until no assignment changes.The standard repair is k-means++, which chooses initial centers with probability proportional to the squared distance from the nearest already-chosen center. It spreads the seeds out, and it converts a heuristic into an algorithm with a guarantee:
k-means++ is O(lg k)-competitive in expectation against the optimum.The k-center objective admits a genuinely simple greedy algorithm with a tight bound.
GREEDY-K-CENTER (farthest-point traversal)
1. Pick any point as the first center.
2. repeat k-1 times:
add as the next center the point farthest from all
centers chosen so far.P = NP, no polynomial-time algorithm achieves a ratio better than 2 — so the greedy algorithm is optimal among efficient algorithms.The proof is a pigeonhole argument. If the greedy solution had a point at distance more than 2r* from every center, then those k+1 points would be pairwise more than 2r* apart, and no k balls of radius r* could cover them all — contradicting the definition of r*.
A beautiful and very general online algorithm. You must make a prediction each day. n experts each offer advice, and you know nothing about their reliability. Afterwards the truth is revealed and you learn who was right.
MULTIPLICATIVE-WEIGHTS
1. Give every expert i an initial weight wᵢ = 1.
2. Each round:
predict according to a weighted vote of the experts
(or pick expert i with probability proportional to wᵢ)
observe the outcome
for each expert i that was wrong:
wᵢ = wᵢ · (1 - ε) // penalise, do not eliminateT rounds with n experts, the expected number of mistakes made by multiplicative weights satisfiesE[mistakes] ≤ (1 + ε) · (mistakes of the best expert) + (ln n)/εThe second term is the regret: how much worse you do than the best expert in hindsight. Choosing ε = √(ln n / T) gives regret O(√(T ln n)), so the average regret per round goes to zero as T grows.
ln n for the privilege.The proof is a potential-function argument in the exact style of Chapter 16. Track the total weight Φ = ∑ wᵢ. Every mistake by the algorithm means a substantial fraction of the weight was on wrong experts, so Φ drops by a constant factor. But Φ is bounded below by the best expert’s surviving weight, (1-ε)m*. Squeezing the two bounds together yields the theorem.
The supervised-learning workhorse. Minimise a differentiable function f(x) by repeatedly stepping downhill.
GRADIENT-DESCENT(f, x₀, η)
1. x = x₀
2. repeat
x = x - η · ∇f(x) // step against the gradient
until convergenceThe gradient ∇f points in the direction of steepest increase, so its negation is the direction of steepest decrease. η is the step size or learning rate.
Step size η | Behaviour |
|---|---|
| Too small | Converges, but very slowly |
| Too large | Overshoots the minimum; may oscillate or diverge |
| Well chosen | Converges at the rate below |
f. For a convex function, every local minimum is global and gradient descent finds it, at rate O(1/t) after t steps, or linearly (error shrinking by a constant factor per step) if the function is also strongly convex. For a non-convex function — every neural network — there are no such guarantees, and you converge to some stationary point with no bound on its quality.This is the same convex-versus-not distinction that separated Chapter 29’s linear programs, which are solvable, from integer programs, which are not.
m training examples, one exact gradient costs Θ(m) work — every example must be touched for every step. With millions of examples and thousands of steps, that is intolerable.m. The estimate is noisy but unbiased — correct in expectation — and it costs O(1) instead of O(m). You take far more steps, each far cheaper, and make much faster progress per unit of work.| Batch GD | SGD | |
|---|---|---|
| Cost per step | Θ(m) | O(1) |
| Gradient quality | Exact | Noisy but unbiased |
| Path | Smooth descent | Jittery |
| Practical | Only for small data | The default everywhere |
O(lg k)-competitive — a heuristic turned into a guaranteed algorithm by randomizing the start.P = NP.(1-ε) and never eliminates them, achieving regret O(√(T ln n)) — only logarithmic in the number of experts.Chapter 34 is the theoretical climax of the book: NP-completeness. It makes precise the intuition from Chapter 1 that some problems have no known efficient algorithm, defines the reduction machinery that relates their difficulty, and proves that a large family of natural problems stand or fall together.