BSCS and MS students can use this guide to study “Understanding Machine Learning: From Theory to Algorithms” by Shai Shalev-Shwartz (The Hebrew University of Jerusalem) and Shai Ben-David (University of Waterloo), first published by Cambridge University Press in 2014. The authors share a free PDF copy for personal use on their official page. The book grew out of the Introduction to Machine Learning courses that the two authors taught, and it is aimed at an advanced undergraduate or beginning graduate course. This page describes the 449-page PDF copy chapter by chapter.
The book is mathematical. It starts from the question “what is learning?” and answers it with PAC learning, the VC-dimension and the bias-complexity tradeoff (Part I), then derives algorithms from those principles: linear predictors, boosting, convex learning, SGD, SVM and kernels, decision trees, nearest neighbor and neural networks (Part II). Part III adds online learning, clustering, dimensionality reduction, generative models and feature selection, and Part IV gives advanced theory for researchers. The authors assume basic probability, linear algebra, analysis and algorithms, so beginners should read Chapters 1 and 2 first and skip the proofs on a first pass.
Book Overview
| Course | Machine Learning (theory) / Statistical Learning Theory |
| Degree Programs | BSCS (advanced elective), MS Computer Science (machine learning) |
| Level | Advanced undergraduate / beginning graduate; Part IV is for researchers |
| Edition | First edition, 2014. The free PDF is almost, but not entirely, identical to the printed version |
| Authors | Shai Shalev-Shwartz (The Hebrew University of Jerusalem) and Shai Ben-David (University of Waterloo) |
| Publisher | Cambridge University Press (ISBN 978-1-107-05713-5, hardback) |
| Total Chapters | 31 chapters in four parts (Part I: 2–8, Part II: 9–20, Part III: 21–25, Part IV: 26–31) plus an introduction (Chapter 1) and 3 appendices |
| Exercises | End-of-chapter exercises in Chapters 2–25, 29 and 31 (none in Chapters 26–28 and 30); no solutions in the PDF, the book says a solution manual is on the course web site |
| Terms of the Free Copy | “This copy is for personal use only. Not for distribution. Do not post. Please link to: http://www.cs.huji.ac.il/~shais/UnderstandingMachineLearning” |
| Language | English |
| Format | PDF — 449 pages (about 2.6 MB) |
Chapter List
The book has 31 chapters in four parts, an introduction chapter before Part I and three appendices. Because that is more than 30 chapters, this page groups them into 15 topic blocks of two or three chapters that never cross a Part boundary: Chapter 1 and the appendices stand alone. Every block follows the same pattern: a summary of what the chapters actually argue, key facts, a tip, a common mistake and two important questions. The page describes the free PDF copy, which has 449 pages.
Chapter 1: Introduction
Difficulty: Easy · Key topics: learning from experience, inductive bias, supervised and unsupervised learning, active and passive learners, online and batch learning, machine learning and statistics, course plans, notation
The book opens by defining machine learning as the conversion of experience, in the form of training data, into expertise, which usually takes the form of another program. Two animal examples carry the argument: rats that avoid poisoned bait learn well because they come with built-in prior knowledge, while Skinner’s pigeons develop superstitions because they accept any explanation for the food that arrives. That prior knowledge is called inductive bias. The chapter then explains when learning is needed, sorts learning paradigms along four axes, compares machine learning with statistics, outlines the four parts of the book, and gives two 14-week course plans and the notation table.
Key Points:
- Learning is the process of converting experience (training data) into expertise (usually another program that performs the task).
- The aim is generalisation: a spam filter that only memorises labelled e-mails cannot label a new one, and inductive reasoning can still reach false conclusions, as the pigeon superstition shows.
- Inductive bias, the prior knowledge that steers a learner, cannot be avoided; Chapter 5 proves this formally as the No-Free-Lunch theorem.
- Machine learning is needed for tasks too complex to program by hand, tasks beyond human ability such as very large data sets, and tasks that need adaptivity.
- Learning paradigms differ along four axes: supervised or unsupervised, active or passive learner, helpful or adversarial teacher, online or batch protocol.
- The book mainly studies supervised statistical batch learning with a passive learner, and treats online learning and clustering more briefly.
- Compared with statistics, machine learning puts more weight on algorithms and computation, on finite-sample bounds instead of asymptotics, and on a distribution-free setting.
Memory Tip: Hold on to the phrase “experience in, expertise out”. For any learning problem, first say what the program receives as experience and what it must hand back as expertise.
Common Mistake: Treating a perfect fit to the training data as the goal. The pigeons in this chapter are perfectly consistent with the food they received and still learn nonsense; what counts is how well the learned rule works on examples it has not seen.
Important Questions:
- Why can a learner not succeed without prior knowledge? Many different rules fit the same finite data. The rats come with a bias (nausea can follow food, an electric shock or a sound cannot), so they generalise correctly, while the pigeons accept any explanation and pick up superstition.
- What is the difference between supervised and unsupervised learning? In supervised learning the training examples carry information, such as spam or not-spam labels, that is missing from the test examples and must be predicted. In unsupervised learning there is no such split and the learner summarises the data, as clustering does.
Chapters 2-4: A Gentle Start, A Formal Learning Model and Learning via Uniform Convergence
Part I: Foundations · Difficulty: Medium · Key topics: statistical learning framework, true risk, empirical risk, ERM, overfitting, hypothesis class, realizability, PAC learning, sample complexity, agnostic PAC learning, loss functions, uniform convergence
Chapter 2 builds the statistical learning framework around a papaya-tasting example: a domain set, a label set, training data, a predictor, an unknown distribution D and a labelling function f, and the true error of a predictor. It shows that Empirical Risk Minimization (ERM) can overfit, using a memorising predictor with zero training error but true error 1/2, and repairs this with a hypothesis class chosen in advance. Chapter 3 turns this into PAC learning with an accuracy parameter ε and a confidence parameter δ, then drops the realizability assumption to define agnostic PAC learning for general loss functions. Chapter 4 introduces ε-representative samples and uniform convergence, and proves that every finite class is agnostic PAC learnable by ERM.
Key Points:
- The true error (risk) of a predictor is the probability, under the unknown distribution D, that it is wrong; the training error is only an estimate of it.
- ERM returns the hypothesis with the lowest training error. Over all possible functions it overfits, so ERM is applied over a restricted hypothesis class H, which is the inductive bias.
- The realizability assumption says some hypothesis in H has zero true error; the i.i.d. assumption says the training examples are drawn independently from D.
- For a finite class under realizability, m ≥ log(|H|/δ)/ε examples guarantee error at most ε with probability at least 1 – δ (Corollary 2.3).
- PAC means probably (confidence 1 – δ) approximately (accuracy ε) correct. Agnostic PAC learning only asks to be within ε of the best hypothesis in H.
- A loss function maps a hypothesis and an example to a nonnegative number, which lets the framework cover regression with the squared loss as well as classification with the 0-1 loss.
- A sample is ε-representative if every hypothesis has training error within ε of its true error; finite classes need about 2 log(2|H|/δ)/ε² examples for agnostic learning (Corollary 4.6).
Memory Tip: Read the three chapters as a ladder of promises. Chapter 2 promises a small error if a perfect hypothesis exists, Chapter 3 relaxes this to “nearly as good as the best in the class”, and Chapter 4 proves it by making every training error close to its true error at once.
Common Mistake: Reading zero training error as success. The memorising predictor in Section 2.2.1 has zero training error on every sample and a true error of 1/2.
Important Questions:
- Why does ERM over all possible functions overfit? A predictor that copies the labels of the training points and answers 0 everywhere else has zero training error whatever the data, yet in the book’s example its true error is 1/2. Restricting ERM to a class H chosen before seeing the data prevents this.
- What is the difference between PAC and agnostic PAC learning? PAC learning assumes some hypothesis in H is perfect (realizability) and asks for small error. Agnostic PAC learning drops that assumption and only asks that, with probability at least 1 – δ, the output is within ε of the best hypothesis in H.
Chapters 5-6: The Bias-Complexity Tradeoff and The VC-Dimension
Part I: Foundations · Difficulty: Hard · Key topics: No-Free-Lunch theorem, universal learner, approximation error, estimation error, shattering, VC-dimension, growth function, Sauer’s lemma, fundamental theorem of statistical learning
Chapter 5 asks whether a universal learner exists and proves that none does: for any learner and any training size below half the domain size, there is a task on which it fails with probability at least 1/7 to get error below 1/8, although another learner could solve that task. It then splits the error of an ERM predictor into approximation error and estimation error, which gives the bias-complexity tradeoff. Chapter 6 shows that infinite classes can still be learnable, defines shattering and the VC-dimension, works examples such as thresholds, intervals and axis aligned rectangles, and states the fundamental theorem of statistical learning, whose proof uses the growth function and Sauer’s lemma.
Key Points:
- No-Free-Lunch: for every learner and every m < |X|/2 there is a distribution, perfectly labelled by some function, on which the learner has error at least 1/8 with probability at least 1/7.
- As a result, the class of all functions over an infinite domain is not PAC learnable, and prior knowledge in the form of a restricted class is essential.
- Error splits into approximation error (the best risk inside H, fixed by the choice of class) and estimation error (shrinks with more data, grows with the complexity of H).
- H shatters a finite set C if every labelling of C is produced by some hypothesis in H; the VC-dimension is the size of the largest shattered set.
- Examples: thresholds on the line have VC-dimension 1, intervals 2, axis aligned rectangles in the plane 4, and a class with one parameter can still have infinite VC-dimension.
- Fundamental theorem: for binary classification with the 0-1 loss, six statements are equivalent, including “H is PAC learnable”, “any ERM rule works” and “H has finite VC-dimension”.
- Quantitatively, agnostic sample complexity grows like (d + log(1/δ))/ε² for VC-dimension d, and the realizable case needs between (d + log(1/δ))/ε and (d log(1/ε) + log(1/δ))/ε.
Memory Tip: The VC-dimension is the largest crowd of points that the class can label in every possible way. “Shatter” just means “every labelling is achievable”.
Common Mistake: Assuming the VC-dimension equals the number of parameters, or that an infinite class cannot be learned. Thresholds are an infinite class with VC-dimension 1, and to prove VCdim(H) = d you must both exhibit a shattered set of size d and show that no set of size d + 1 is shattered.
Important Questions:
- Does a universal learner exist? No. By the No-Free-Lunch theorem every learner fails on some distribution that another learner could handle, so every successful learner needs prior knowledge, such as a restricted hypothesis class.
- What does the fundamental theorem of statistical learning say? For binary classification with the 0-1 loss, a class is PAC learnable if and only if its VC-dimension is finite, and in that case uniform convergence holds and any ERM rule learns it, with sample complexity set by the VC-dimension.
Chapters 7-8: Nonuniform Learnability and The Runtime of Learning
Part I: Foundations · Difficulty: Hard · Key topics: nonuniform learnability, structural risk minimization, minimum description length, Occam’s razor, consistency, computational complexity of learning, proper and improper learning, hardness of learning
Chapter 7 relaxes PAC learning so that the sample size may depend on the hypothesis we compare against. A class is nonuniformly learnable exactly when it is a countable union of agnostic PAC learnable classes, and Structural Risk Minimization (SRM) learns it by trading training error against a complexity penalty. For countable classes this becomes Minimum Description Length (MDL) and Occam’s razor, and consistency is the weakest notion discussed. Chapter 8 then asks how much computation learning needs. ERM is efficient for rectangles and Boolean conjunctions in the realizable case, NP-hard in the agnostic case, and NP-hard for 3-term DNF even in the realizable case, although that class is learnable efficiently by a different representation.
Key Points:
- Nonuniform learnability lets the sample size depend on the competing hypothesis h; a class qualifies if and only if it is a countable union of agnostic PAC learnable classes (Theorem 7.2).
- SRM orders the classes and picks the hypothesis minimising training error plus a penalty that grows with the index of its class.
- MDL: with a prefix-free description language, L_D(h) ≤ L_S(h) + sqrt((|h| + ln(2/δ))/(2m)), so shorter descriptions are preferred (Occam’s razor); the Kraft inequality justifies prefix-free codes.
- The class of all predictors written in C++ is learnable by MDL, but the search is exhaustive: ERM over programs of at most 1000 bits needs at least 2^1000 steps.
- Computational complexity of learning is measured as a function of 1/ε, 1/δ and the problem size; ERM for Boolean conjunctions is efficient under realizability but NP-hard in the agnostic case.
- 3-term DNF cannot be learned by a proper ERM (NP-hard even if realizable), yet it can be learned efficiently by mapping to conjunctions over about (2n)^3 variables, an example of representation independent learning.
- Hardness results for learning can be derived from cryptographic assumptions such as one-way and trapdoor functions.
Memory Tip: SRM is ERM with a price tag on complexity: a richer hypothesis must earn its place with a lower training error. And remember the difference in questions: statistics asks how many examples, computer science also asks how many steps.
Common Mistake: Equating “learnable” with “efficiently learnable”. Chapter 7 ends with a class that is learnable from few examples but that nobody can search in practice, which is exactly why Chapter 8 exists.
Important Questions:
- How is nonuniform learnability different from PAC learnability? In PAC learning the sample size depends only on ε and δ. In nonuniform learning it may also depend on the hypothesis you want to compete with, so classes with infinite VC-dimension, such as polynomial classifiers of every degree, can still be learned.
- Can a class be easy statistically but hard computationally? Yes. Boolean conjunctions have finite VC-dimension, so they are statistically learnable in both the realizable and the agnostic case, but implementing ERM is efficient only in the realizable case. 3-term DNF is hard for ERM even when realizable, although switching to a larger class makes it efficiently learnable.
Chapters 9-11: Linear Predictors, Boosting and Model Selection and Validation
Part II: From Theory to Algorithms · Difficulty: Medium · Key topics: halfspaces, linear programming, Perceptron, least squares, polynomial regression, logistic regression, weak learner, AdaBoost, decision stumps, validation, k-fold cross validation
Chapter 9 introduces linear predictors: halfspaces, learned either by linear programming or by the Perceptron, linear regression solved by least squares (with polynomial regression as a linear model over monomial features), and logistic regression with the sigmoid function. Chapter 10 presents boosting: a gamma-weak learner is only slightly better than guessing, and AdaBoost reweights the examples and combines weak hypotheses into a strong one, with the number of rounds T controlling the bias-complexity tradeoff. It ends with AdaBoost for face detection. Chapter 11 answers how to set such parameters, using SRM, a hold-out set, k-fold cross validation and a train-validation-test split, and explains what to do when learning fails.
Key Points:
- A halfspace predicts the sign of
<w, x> + b; the VC-dimension of homogeneous halfspaces in R^d is d, and of non-homogeneous halfspaces d + 1. - Perceptron: start with w = 0 and, while some example has
y_i<w, x_i> ≤ 0, addy_i x_ito w. On separable data it stops after at most (RB)^2 updates. - Least squares solves the linear system Aw = b with A the sum of x_i x_i^T and b the sum of y_i x_i; polynomial regression is linear regression after mapping x to its monomials.
- Logistic regression predicts the sigmoid of
<w, x>and uses the loss log(1 + exp(-y<w, x>)), which is convex and can be minimised efficiently. - AdaBoost: if every weak hypothesis has error at most 1/2 – γ, the training error of the output after T rounds is at most exp(-2γ²T); the number of rounds T tunes approximation against estimation error.
- A hold-out validation set estimates the true error; k-fold cross validation (leave-one-out when k = m) does this without wasting data, and a final test set that is never used for tuning gives an honest estimate.
- When learning fails, compare training and validation error: a large training error means underfitting (enlarge the class or change the features), a large gap means overfitting (more data or a smaller class).
Memory Tip: Perceptron in one line: if the current weights get an example wrong, nudge them toward that example’s label. AdaBoost in one line: raise the weight of the examples the last rule got wrong.
Common Mistake: Expecting the Perceptron to stop on any data set. Theorem 9.1 covers separable data only; if the data cannot be separated by a halfspace the loop never ends. A second slip is tuning parameters on the test set, which uses up the only honest estimate you had.
Important Questions:
- When does the Perceptron algorithm stop, and how fast? It stops only when the training set is linearly separable, and then after at most (RB)² updates, where R is the largest norm of an instance and B is the smallest norm of a weight vector that separates the data with margin 1.
- Why split data into training, validation and test sets? The validation set is used to choose parameters such as the number of boosting rounds, so its error becomes optimistic. The test set is touched once, after all choices are made, to estimate the true error of the final predictor.
Chapters 12-13: Convex Learning Problems and Regularization and Stability
Part II: From Theory to Algorithms · Difficulty: Hard · Key topics: convex sets and functions, Lipschitzness, smoothness, convex-Lipschitz-bounded problems, surrogate loss, hinge loss, regularized loss minimization, Tikhonov regularization, ridge regression, stability, strong convexity
Chapter 12 defines convex sets and functions, Lipschitzness and smoothness, and calls a problem convex when the hypothesis class is a convex set and the loss is convex for each example. Convexity alone is not enough, since linear regression with unbounded weights is not learnable even in one dimension, so the book singles out the convex-Lipschitz-bounded and convex-smooth-bounded families and introduces convex surrogate losses such as the hinge loss. Chapter 13 shows that both families are learnable with Regularized Loss Minimization (RLM). Adding a Tikhonov term makes the algorithm stable, a stable rule does not overfit, and the regularization parameter controls the fitting-stability tradeoff; ridge regression is the main example.
Key Points:
- A function f is convex if f(αu + (1 – α)v) ≤ αf(u) + (1 – α)f(v); the 0-1 loss for halfspaces is not convex, which is why it is hard to minimise.
- f is ρ-Lipschitz if |f(u) – f(v)| ≤ ρ||u – v||, and β-smooth if its gradient is β-Lipschitz; these control how fast the loss can change.
- Convex-Lipschitz-bounded and convex-smooth-bounded problems (with the weight vector confined to a ball of radius B) are the two families shown to be learnable in Chapters 13 and 14.
- Convexity without boundedness fails: Example 12.8 shows that linear regression with the squared loss over an unbounded class is not learnable even for d = 1.
- A surrogate loss is a convex upper bound of the loss we really care about; the hinge loss max{0, 1 – y<w, x>} replaces the 0-1 loss for halfspaces.
- RLM minimises the training loss plus a regularizer; with the Tikhonov regularizer λ||w||² and the squared loss this is ridge regression, solved by (2λmI + A)w = b.
- A stable algorithm, whose output barely changes when one training example is replaced, does not overfit; λ-strong convexity of the objective gives stability, and λ trades fitting against stability.
Memory Tip: Picture a bowl. A convex loss has a single valley, so stepping downhill cannot get trapped; Lipschitz and smooth tell you how steep the bowl’s walls are, and the regularizer keeps the bottom from jumping around when one example changes.
Common Mistake: Thinking regularization is only a trick to keep the numbers small. It works because it stabilises the learner, and too large a λ simply underfits.
Important Questions:
- Why use the hinge loss instead of the 0-1 loss? Minimising the 0-1 loss over halfspaces is a nonconvex problem that is computationally hard when the data are not separable. The hinge loss is convex and upper bounds the 0-1 loss, so a small hinge risk gives a small 0-1 risk and the problem can be solved efficiently.
- What does the parameter λ control in regularized loss minimization? It sets the fitting-stability tradeoff. A small λ fits the training set closely but is less stable and may overfit; a large λ makes the learner stable but pushes the solution toward zero and underfits.
Chapters 14-16: Stochastic Gradient Descent, Support Vector Machines and Kernel Methods
Part II: From Theory to Algorithms · Difficulty: Hard · Key topics: gradient descent, subgradients, stochastic gradient descent, margin, Hard-SVM, Soft-SVM, duality, feature maps, kernel trick, representer theorem, polynomial and Gaussian kernels
Chapter 14 analyses gradient descent for convex Lipschitz functions: with a suitable step size the averaged iterate is within Bρ/√T of the optimum after T steps. Subgradients extend this to functions such as the hinge loss, and Stochastic Gradient Descent (SGD) replaces the gradient by a random vector whose expectation is a subgradient, so one fresh example per step minimises the risk directly. Chapter 15 introduces the margin and the SVM: Hard-SVM for separable data, Soft-SVM with slack variables, a sample complexity that depends on norms rather than dimension, and an SGD implementation. Chapter 16 embeds data in a feature space, shows that only inner products are needed, and builds the kernel trick, the representer theorem and polynomial and Gaussian kernels.
Key Points:
- Gradient descent updates w by subtracting η times the gradient; for a convex ρ-Lipschitz function the averaged output satisfies f(w) – f(w*) ≤ Bρ/√T, so about B²ρ²/ε² iterations give accuracy ε.
- A subgradient generalises the gradient to nondifferentiable convex functions; the hinge loss has an easy subgradient, which is what makes SVM training by SGD possible.
- SGD uses a random v_t with E[v_t | w] a subgradient; for risk minimisation, drawing a fresh example from D at each step gives an unbiased estimate, so the iteration bound is also a sample complexity bound.
- Hard-SVM minimises ||w|| subject to y_i(<w, x_i> + b) ≥ 1, i.e. it finds the largest margin; Soft-SVM minimises λ||w||² plus the average slack and equals RLM with the hinge loss.
- The sample complexity of SVM depends on the norm of w and of the instances (the margin), not on the dimension of the space, so very high or infinite dimensions are affordable.
- A kernel K(x, x’) = <ψ(x), ψ(x’)> gives inner products in feature space without computing ψ; examples are the polynomial kernel (1 + <x, x’>)^k and the Gaussian kernel exp(-||x – x’||²/(2σ)).
- The representer theorem says an optimal w can be written as a combination of the mapped training points, and a symmetric function is a kernel if and only if every Gram matrix is positive semidefinite.
Memory Tip: Three roles: SGD is the engine, the SVM is the model (a large-margin halfspace trained by SGD), and the kernel is the lens that lets the same linear model bend to a nonlinear problem.
Common Mistake: Believing a higher-dimensional feature space always needs more data. For the SVM the bound depends on the margin and norms, not on the dimension, which is exactly why the kernel trick may use infinite-dimensional spaces.
Important Questions:
- What is the kernel trick? To learn a halfspace in a feature space you only need inner products between mapped instances. A kernel function computes them directly from the original instances, and by the representer theorem the solution is a combination of the mapped training points, so the feature map is never built.
- How does Soft-SVM differ from Hard-SVM? Hard-SVM demands y_i(<w, x_i> + b) ≥ 1 for every example, so the data must be separable. Soft-SVM allows violations through slack variables and minimises λ||w||² plus the average slack, which is regularized hinge-loss minimisation and works on non-separable data.
Chapters 17-18: Multiclass, Ranking and Complex Prediction Problems and Decision Trees
Part II: From Theory to Algorithms · Difficulty: Medium · Key topics: One-versus-All, All-Pairs, linear multiclass predictors, structured output, ranking, Kendall tau, NDCG, decision trees, ID3, information gain, pruning, random forests
Chapter 17 starts with reductions of multiclass learning to binary learning, One-versus-All and All-Pairs, and shows with a three-class example that they can be suboptimal. It then builds linear multiclass predictors from a feature map of instance and label, with a generalized hinge loss trained by SGD, extends this to structured output such as recognising a handwritten word with dynamic programming, and treats ranking and bipartite ranking with losses such as Kendall tau and NDCG. Chapter 18 covers decision trees: their sample complexity and the need to limit tree size, the ID3 algorithm with three gain measures, pruning, thresholds for real-valued features, and random forests.
Key Points:
- One-versus-All trains one binary classifier per class and All-Pairs one per pair of classes; both are simple, but the binary learner does not know how its output will be combined.
- A linear multiclass predictor returns the label y maximising
<w, Ψ(x, y)>for a feature map Ψ, and is trained by ERM with a generalized hinge loss and SGD (multiclass SVM). - Structured output prediction labels a whole sequence at once; for word recognition the features include which letter follows which, and prediction is done by dynamic programming over positions.
- Ranking predicts scores whose order gives a permutation; the Kendall tau loss counts mis-ordered pairs and NDCG stresses the top of the list; bipartite ranking and F1 are handled with similar surrogate losses.
- A decision tree with k leaves can shatter k instances, so trees of arbitrary size have infinite VC-dimension and the MDL idea is used to prefer small trees.
- ID3 grows a tree by repeatedly choosing the feature with the highest gain: decrease in training error, information gain (entropy) or the Gini index 2a(1 – a); pruning then cuts the tree back.
- A random forest is a majority vote over trees, each grown on a random subsample and a random subset of features, which reduces overfitting.
Memory Tip: The three gain measures are three impurity curves of the fraction a of positive labels at a node: min{a, 1 – a}, entropy and 2a(1 – a). All are zero for a pure node and largest at a = 1/2.
Common Mistake: Growing an ID3 tree until training error is zero. The tree is usually very large, with low empirical risk but high true risk, so limit its size or prune it.
Important Questions:
- Why can a decision tree of arbitrary size overfit? A tree with k leaves can shatter a set of k instances, so allowing any size gives an infinite VC-dimension. The book therefore uses the MDL principle, asking for a tree that fits the data well without being large.
- What is the weakness of the One-versus-All reduction? Each binary learner is trained without knowing its output will be combined into a multiclass decision. In the book’s three-class example, with class masses of 40%, 20% and 40% and halfspaces as the binary learner, this leads to a suboptimal predictor.
Chapters 19-20: Nearest Neighbor and Neural Networks
Part II: From Theory to Algorithms · Difficulty: Medium · Key topics: k nearest neighbors, 1-NN generalization bound, curse of dimensionality, feedforward neural networks, expressive power, VC-dimension of networks, hardness of training, SGD, backpropagation
Chapter 19 describes the nearest neighbor rule, which memorises the training set and labels a new point by its closest neighbours instead of searching a hypothesis class. If the conditional label probability is Lipschitz, the expected error of 1-NN is at most twice the Bayes error plus a term that shrinks slowly with the sample size, and a lower bound exposes the curse of dimensionality. Chapter 20 defines feedforward neural networks as weighted directed acyclic graphs, studies what they can express, bounds their sample complexity through the number of edges, proves that training them is computationally hard, and presents SGD with backpropagation as the standard heuristic.
Key Points:
- k-NN predicts by the labels of the k closest training points; unlike ERM, SRM or RLM it does not search a predefined hypothesis class.
- Theorem 19.3: if the conditional probability of label 1 is c-Lipschitz on [0,1]^d, the expected error of 1-NN is at most 2 times the Bayes optimal error plus 4c√d m^(-1/(d+1)).
- Curse of dimensionality: a lower bound shows the sample size may have to grow exponentially with d, so NN is usually applied after dimensionality reduction (Chapter 23).
- A neural network is a directed acyclic graph of neurons with a weight on each edge and an activation such as sign or sigmoid; the weights are the parameters of the hypothesis.
- Networks whose size is polynomial in n can implement everything computable in polynomial time, but representing arbitrary Boolean functions on n bits needs exponential size (Theorem 20.2).
- The VC-dimension of a sign network is O(|E| log |E|), so sample complexity depends on the number of edges.
- ERM is NP-hard even for a network with one hidden layer of a few neurons; SGD with backpropagation, which computes the gradient with respect to all edge weights efficiently, is therefore a heuristic.
Memory Tip: Count edges, not neurons: the book’s sample complexity bound for a network grows with the number of edges, which is the number of weights.
Common Mistake: Reading Chapter 20 as a guide to modern deep learning. It analyses feedforward networks with sign and sigmoid units in theory; convolutional networks are only mentioned in passing, and recurrent networks, ReLU units and training practice are not covered.
Important Questions:
- Why does nearest neighbor struggle in high dimensions? The error bound contains the term m^(-1/(d+1)), which shrinks extremely slowly when d is large, and a matching lower bound shows an exponential number of examples may be needed. Reducing the dimension first, for example with PCA, is the usual remedy.
- Why is training a neural network hard although its sample complexity is fine? The class is rich enough to be learned from a moderate sample, but finding an ERM hypothesis is NP-hard even for tiny networks, and even finding weights with close-to-minimal error is infeasible, so practical training relies on SGD and backpropagation as a heuristic.
Chapters 21-23: Online Learning, Clustering and Dimensionality Reduction
Part III: Additional Learning Models · Difficulty: Hard · Key topics: mistake bounds, Halving, Littlestone dimension, Weighted-Majority, online gradient descent, online Perceptron, linkage clustering, k-means, spectral clustering, PCA, random projections, compressed sensing
Chapter 21 drops the split between training and prediction: in each round the learner predicts an example’s label and only then sees the truth. In the realizable case it studies mistake bounds, the Halving algorithm and the Littlestone dimension, in the unrealizable case regret and the Weighted-Majority algorithm, and then online convex optimization and the online Perceptron. Chapter 22 treats clustering, an unsupervised task with no ground truth: linkage-based algorithms, k-means, spectral clustering, the information bottleneck and Kleinberg’s impossibility result. Chapter 23 reduces dimension by linear maps: PCA, random projections with the Johnson-Lindenstrauss lemma, and compressed sensing for sparse vectors.
Key Points:
- In online learning each round brings x_t, a prediction, and then the true label; success is measured by the number of mistakes (realizable case) or by regret against the best hypothesis (unrealizable case).
- For a finite class the Consistent algorithm makes at most |H| – 1 mistakes, while Halving, which predicts by majority vote over the version space, makes at most log2|H|.
- The Littlestone dimension, defined with shattered trees, characterises online learnability the way the VC-dimension characterises PAC learnability; the SOA algorithm makes at most Ldim(H) mistakes.
- Online gradient descent has regret at most Bρ√T for convex ρ-Lipschitz losses over a B-bounded set, and the online Perceptron is this algorithm applied to a surrogate hinge loss.
- Clustering has no ground truth: single linkage builds a dendrogram (related to Kruskal’s minimum spanning tree), k-means minimises a cost with iterations that never increase it, and spectral clustering uses the graph Laplacian.
- Kleinberg’s theorem: no clustering function can satisfy scale invariance, richness and consistency at the same time.
- PCA projects onto the top eigenvectors of the sum of x_i x_i^T, which minimises average squared reconstruction error among linear compressions; random projections keep distances (Johnson-Lindenstrauss), and compressed sensing recovers s-sparse vectors from about s log d random measurements.
Memory Tip: In the online model the same papaya is first a test example and then a training example. In clustering there is no label to check against, so always ask what the algorithm assumes “similar” means.
Common Mistake: Running a clustering algorithm and expecting it to find the “right” groups. The chapter shows that single linkage and 2-means split the same input in different ways, and no ground truth decides between them.
Important Questions:
- What is the Littlestone dimension used for? It plays the role of the VC-dimension in online learning: a class has a finite mistake bound in the realizable case exactly when its Littlestone dimension is finite, and the SOA algorithm makes at most Ldim(H) mistakes.
- How does PCA choose its directions? It looks for the n-dimensional subspace that minimises the average squared reconstruction error of the data. The solution is given by the eigenvectors of the matrix sum of x_i x_i^T with the n largest eigenvalues.
Chapters 24-25: Generative Models and Feature Selection and Generation
Part III: Additional Learning Models · Difficulty: Medium · Key topics: maximum likelihood, Naive Bayes, linear discriminant analysis, latent variables, EM algorithm, Bayesian reasoning, feature selection, filters, greedy selection, LASSO, feature normalization, dictionary learning, auto-encoders
Chapter 24 leaves the distribution-free framework and assumes that data come from a parametric family whose parameters we estimate. It covers the maximum likelihood principle and its link to ERM, the Naive Bayes classifier, which assumes features are independent given the label, linear discriminant analysis with shared-covariance Gaussians, the EM algorithm for latent variables such as a mixture of Gaussians, and Bayesian reasoning. Chapter 25 turns to the representation of the instances: feature selection with filters, greedy algorithms and sparsity-inducing norms, feature normalization and transformation, and feature learning through dictionary learning with auto-encoders.
Key Points:
- The generative approach assumes a parametric form for the data distribution and estimates its parameters; the discriminative approach of earlier chapters learns a predictor directly, following Vapnik’s advice not to solve a harder problem as an intermediate step.
- Maximum likelihood picks the parameters that maximise the log-likelihood of the sample, and it can be read as ERM with the log loss.
- Naive Bayes assumes the features are independent given the label, which cuts the number of parameters from exponential in d to only 2d + 1.
- With equal class priors and Gaussian classes sharing one covariance matrix, the Bayes optimal rule of linear discriminant analysis is a linear classifier.
- EM maximises the likelihood when some variables are hidden by alternating between estimating posterior probabilities and re-estimating parameters; for a mixture of Gaussians it is a soft version of k-means.
- Feature selection uses filters (score each feature separately), greedy forward or backward selection (Orthogonal Matching Pursuit is an example) and the l1 norm, which gives the LASSO.
- Common feature transformations are centering, unit range scaling, standardization, clipping, sigmoidal and logarithmic transformations; dictionary learning with auto-encoders learns features from unlabelled data.
Memory Tip: Naive Bayes is “naive” because it pretends features are independent given the label, and that single assumption is what turns an exponential table into 2d + 1 numbers.
Common Mistake: Using a generative model when the assumed distribution is wrong and expecting the predictor to be robust. The book notes that the discriminative approach optimises prediction accuracy directly, while the generative approach is a good choice when parameter estimation is easier or when you want to model the data itself.
Important Questions:
- Why does Naive Bayes need so few parameters? Describing P[Y = y | X = x] for all x in {0,1}^d takes about 2^d parameters. Assuming the features are independent given the label reduces this to 2d + 1 parameters, estimated by maximum likelihood.
- What is the difference between feature selection and feature learning? Feature selection chooses a good subset of the features you already measure, using filters, greedy search or l1 regularization. Feature learning builds new features from the data, for example the dictionary elements learned by an auto-encoder.
Chapters 26-27: Rademacher Complexities and Covering Numbers
Part IV: Advanced Theory · Difficulty: Hard · Key topics: Rademacher complexity, McDiarmid inequality, Massart lemma, contraction lemma, linear classes, SVM generalization bounds, l1 norm bounds, covering numbers, chaining
Chapter 26 studies Rademacher complexity, a measure of how well a class can correlate with random signs, and uses it to bound the rate of uniform convergence. It proves that the expected gap between true and training error of ERM is at most twice the expected Rademacher complexity, adds McDiarmid’s inequality for high-probability bounds, and builds a calculus with the Massart and contraction lemmas. It then bounds the complexity of linear classes with bounded l2 or l1 norm, giving dimension-free generalization bounds for SVM. Chapter 27 introduces covering numbers and shows, through Dudley’s chaining technique, how to bound the Rademacher complexity from them.
Key Points:
- The Rademacher complexity of a set A of vectors is the expected value of the best correlation sup over a of the sum of σ_i a_i with random signs σ_i, divided by m.
- Theorem 26.3: the expected gap between the true and training error of ERM is at most 2 times the expected Rademacher complexity of the loss class on the sample.
- Massart lemma: for a finite set of N vectors the Rademacher complexity grows only like √(2 log N), and the contraction lemma shows that applying a ρ-Lipschitz function multiplies it by at most ρ.
- For linear classes with ||w||_2 ≤ 1 the complexity is at most the largest ||x_i|| divided by √m (Lemma 26.10); with ||w||_1 ≤ 1 it is at most max ||x_i||_inf times √(2 log(2n)/m) (Lemma 26.11).
- Theorem 26.12: for ||x|| ≤ R, ||w|| ≤ B and a ρ-Lipschitz loss, the true risk is at most the training risk plus 2ρBR/√m plus a confidence term, which contains no dimension and underlies the SVM bounds.
- The covering number N(r, A) is the size of the smallest set that r-covers A; a subspace of dimension d inside a ball of radius c has N(r, A) ≤ (2c√d / r)^d.
- Chaining (Dudley) bounds the Rademacher complexity by a sum over scales of √log N(c 2^(-k), A), and for a ρ-Lipschitz map φ the covering numbers satisfy N(ρr, φ(A)) ≤ N(r, A).
Memory Tip: Rademacher complexity asks one question: if the labels were replaced by coin flips, how well could the class still fit them? A class that can fit noise well will also overfit real data.
Common Mistake: Using the SVM bound as if it depended on the number of features. Theorem 26.12 involves only ρ, B, R, m and δ; the dimension never appears, which is its whole point.
Important Questions:
- What does Rademacher complexity measure? It measures how well a set of vectors, such as the loss values of a hypothesis class on a sample, can correlate with random plus and minus one signs. Larger values mean the class can fit noise better, which means a larger gap between training and true error.
- Why can SVM generalization be analysed without the dimension? For linear classes with bounded norm, the Rademacher complexity is at most B times R divided by √m, where R bounds the instance norm. Combined with the contraction lemma for a Lipschitz loss, the generalization bound depends on B, R and m only.
Chapters 28-29: Proof of the Fundamental Theorem of Learning Theory and Multiclass Learnability
Part IV: Advanced Theory · Difficulty: Hard · Key topics: agnostic upper bound, agnostic lower bound, realizable upper bound, epsilon-nets, Natarajan dimension, multiclass fundamental theorem, good and bad ERMs
Chapter 28 proves the quantitative fundamental theorem stated in Chapter 6 for a class of VC-dimension d with the 0-1 loss. It proves a slightly looser version of the agnostic upper bound, proves the agnostic lower bound in two parts (one with the confidence term and one with the dimension term), and proves the realizable upper bound through ε-nets. Chapter 29 asks the same questions for multiclass problems. It defines the Natarajan dimension as a generalisation of the VC-dimension, states a multiclass fundamental theorem, computes the dimension for several classes, and gives an example showing that a class can be learnable by one ERM but not by another.
Key Points:
- Chapter 28 proves the sample complexity bounds of Theorem 6.8 for a class H of {0,1}-valued functions with VCdim(H) = d, using the 0-1 loss.
- The agnostic lower bound has two parts: m(ε, δ) is at least about log(1/(4δ))/ε², and m(ε, 1/8) is at least about 8d/ε².
- The realizable upper bound uses ε-nets: a sample that hits every subset of probability mass at least ε makes ERM accurate, and the proof goes from ε-nets to PAC learnability.
- The Natarajan dimension is the size of the largest multiclass-shattered set, and for exactly two labels it equals the VC-dimension.
- Multiclass fundamental theorem: with Natarajan dimension d and k labels, agnostic sample complexity lies between (d + log(1/δ))/ε² and (d log k + log(1/δ))/ε² up to constants.
- Section 29.3 calculates the Natarajan dimension for One-versus-All based classes, general multiclass-to-binary reductions and linear multiclass predictors.
- Section 29.4: a class built from finite and cofinite subsets can be learned by some ERM rules while other ERM rules fail, so for multiclass problems uniform convergence is not necessary for learnability.
Memory Tip: Chapter 28 gives the theorem three jobs: show that enough examples suffice (upper bound), show that fewer do not (lower bound), and show that the realizable case is cheaper (ε-nets).
Common Mistake: Assuming the binary statement “any ERM rule works” carries over to more than two labels. Section 29.4 gives a learnable multiclass class where a bad ERM fails.
Important Questions:
- What is the Natarajan dimension? It generalises the VC-dimension to k labels. A set C is shattered if there are two label functions f0 and f1 that disagree at every point of C and, for every subset B of C, some hypothesis follows f0 on B and f1 on the rest; the Natarajan dimension is the size of the largest shattered set, and with two labels it equals the VC-dimension.
- Does every ERM rule learn a learnable multiclass class? No. Section 29.4 builds a class that is learnable by a suitable ERM while another ERM rule fails, so, unlike the binary case, the class is learnable without having the uniform convergence property.
Chapters 30-31: Compression Bounds and PAC-Bayes
Part IV: Advanced Theory · Difficulty: Hard · Key topics: compression scheme, compression bound, axis aligned rectangles, halfspaces, margin, prior and posterior, PAC-Bayes bound, KL divergence
Chapter 30 gives a new sufficient condition for learning: if an algorithm can express its output using a small subset of the training examples, the error on the remaining examples estimates the true error. It defines compression schemes, proves a bound that depends on the subset size k, and shows examples with axis aligned rectangles, halfspaces, separating polynomials and large-margin separation. Chapter 31 generalises the MDL idea: prior knowledge is expressed as a prior distribution over the hypothesis class, and the learner returns a posterior distribution. The PAC-Bayes bound controls the risk of the posterior through its Kullback-Leibler divergence from the prior, and minimising it resembles regularized loss minimisation.
Key Points:
- A compression scheme of size k has two parts: A selects k examples from the sample and B rebuilds a hypothesis from only those k.
- Theorem 30.2: with probability at least 1 – δ, the true error of A(S) is at most its error on the unused examples plus a term of order √(k log(m/δ)/m) times that error plus 8k log(m/δ)/m.
- Axis aligned rectangles have a compression scheme of size 2d (the extreme positive examples in each dimension), and homogeneous halfspaces one of size d via the minimum-norm point of the convex hull.
- PAC-Bayes puts a prior P over H and lets the learner return a posterior Q, a distribution over hypotheses, instead of a single hypothesis.
- Theorem 31.1: with probability at least 1 – δ, for all posteriors Q, the risk of Q is at most its training risk plus √((D(Q||P) + ln(m/δ))/(2(m – 1))), where D is the Kullback-Leibler divergence.
- Minimising that bound gives a rule like RLM: empirical loss of Q plus a penalty for how far Q moves from the prior.
- The loss in the PAC-Bayes theorem must lie in [0, 1], and the bound holds simultaneously for every posterior, even one chosen after seeing the sample.
Memory Tip: A hypothesis that can be written down with only k training examples has little room to memorise noise; PAC-Bayes says the same about a posterior that stays close to the prior.
Common Mistake: Reading the PAC-Bayes bound as a guarantee for one fixed hypothesis. It bounds the average risk of a hypothesis drawn at random from the posterior Q.
Important Questions:
- What is the idea of a compression bound? If a learning rule can reproduce its output from just k of the m training examples, the remaining m – k examples act as a fresh test set for it. The error on them therefore estimates the true error, with a penalty that grows with k.
- What does the PAC-Bayes bound say? For a prior P chosen before seeing data, the risk of any posterior Q is bounded by its training risk plus a term that grows with the KL divergence between Q and P. A posterior close to the prior, or one that fits the data well, generalizes well.
Appendices A-C: Technical Lemmas, Measure Concentration and Linear Algebra
Appendix · Difficulty: Medium · Key topics: technical lemmas, Markov, Chebyshev, Chernoff, Hoeffding, Bennet and Bernstein inequalities, eigenvalues and eigenvectors, positive definite matrices, singular value decomposition
Appendix A collects technical lemmas used in the proofs, including how to solve inequalities of the form x ≥ a log x that appear when a bound is turned into a sample size, and a bound on sums of binomial coefficients needed for Sauer’s lemma. Appendix B on measure concentration quantifies how far an empirical average can be from its expectation for finite m, covering Markov’s, Chebyshev’s, Chernoff’s, Hoeffding’s, Bennet’s and Bernstein’s inequalities, Slud’s inequality and the concentration of chi-squared variables. Appendix C reviews linear algebra over finite-dimensional Euclidean spaces: inner products and norms, subspaces, eigenvalues and eigenvectors, positive definite matrices and the singular value decomposition.
Key Points:
- Lemma A.1: x ≥ 2a log(a) implies x ≥ a log(x), the tool for turning a bound into an explicit sample size.
- Lemma A.5: for d ≤ m – 2 the sum of binomial coefficients C(m, k) for k from 0 to d is at most (em/d)^d.
- Markov’s inequality bounds the tail of a nonnegative random variable by its mean, and Chebyshev’s inequality bounds the deviation of a variable from its mean using the variance.
- Hoeffding’s inequality: for i.i.d. variables in [a, b], the average deviates from the mean by more than ε with probability at most 2 exp(-2mε²/(b – a)²); it is used from Chapter 4 on.
- Bennet’s and Bernstein’s inequalities give sharper bounds when the variance is small, and Appendix B also covers Slud’s inequality and chi-squared concentration.
- Every symmetric matrix has a spectral decomposition A = VDV^T, which is used in the PCA proof of Chapter 23; Appendix C also defines positive definite matrices and the SVD.
Memory Tip: Appendix B is the engine room of Parts I and IV: nearly every sample complexity bound ends in Hoeffding’s inequality or a relative of it. Appendix C is the refresher to read before Chapters 9, 15 and 23.
Common Mistake: Skipping the appendices and then treating the concentration inequalities as magic. Chapter 4 states Hoeffding’s inequality without proof and sends the reader to Appendix B.
Important Questions:
- What does Hoeffding’s inequality say, and where is it used first? The average of m independent variables bounded in [a, b] stays within ε of its mean with probability at least 1 – 2 exp(-2mε²/(b – a)²). Chapter 4 uses it to show that the training error of a fixed hypothesis is close to its true error.
- Which linear algebra tools does the book assume you know? Inner products and norms, subspaces, eigenvalues and eigenvectors, positive (semi)definite matrices and the singular value decomposition. Appendix C summarises them, and Chapters 9, 15, 16, 22 and 23 use them most.
How to Study This Book
The free PDF has 449 pages and 31 chapters. Chapter 1 is an introduction, Part I (Chapters 2 to 8) builds the foundations of learning theory, Part II (Chapters 9 to 20) turns the theory into algorithms, Part III (Chapters 21 to 25) adds other learning models and Part IV (Chapters 26 to 31) is advanced theory, followed by three appendices. Do not plan to read it cover to cover. The blocks above group the chapters by topic and keep the Part boundaries, so you can see which block each chapter number belongs to.
Check your prerequisites honestly. The preface says the authors tried to keep the book self-contained, but the reader is assumed to be comfortable with basic probability, linear algebra, analysis and algorithms. The first three parts are intended for first year graduate students in computer science, engineering, mathematics or statistics, and the book can also be accessible to undergraduates with the right background; the more advanced chapters are for researchers. In practice you need expectations, the union bound and independent samples for Chapters 2 to 4, inner products, norms and gradients for Chapters 9 to 16, and eigenvectors for Chapters 22 and 23. Appendix C is a short linear algebra refresher and Appendix B proves the concentration inequalities used throughout.
The authors give two 14-week course plans in Section 1.5.1. The introductory graduate course uses Chapters 2 to 4, then Chapter 9 (without the VC calculation), Chapters 5 and 6 (without proofs), Chapter 10, Chapters 7 and 11 (without proofs), Chapters 12 and 13 (with some of the easier proofs), Chapter 14, then Chapters 15, 16, 18, 22, 23 (without the compressed sensing proofs), 24 and 25. The advanced course starts with Chapters 26 and 27, then Chapters 6 and 28, 7, 31, 30, 12 and 13, 14, 8, 17, 29, 19, 20 and 21. A few sections are marked with an asterisk, which means they are addressed to more advanced students, so skip those on a first pass.
For a BSCS machine learning elective, a practical path through the first read is Chapter 1, then the definitions in Chapters 2 and 3, then Chapter 9 for the Perceptron, linear regression and logistic regression, and Chapter 11 for validation and cross validation, which you will use in every project. After that read Chapter 10 on boosting, Chapter 18 on decision trees and random forests, Chapter 19 on nearest neighbor, Section 14.3 for the SGD algorithm, Chapter 15 on SVM, the idea of the kernel trick in Chapter 16, Chapter 20 on neural networks, Chapter 22 on clustering, Section 23.1 on PCA, Sections 24.1 to 24.3 on maximum likelihood, Naive Bayes and LDA, and Chapter 25 on features. Skip the proofs and read the statements of the theorems and the summaries.
For MS and research reading, follow the dependencies. Read Chapters 2 to 6 in order, since each uses the previous one, and add Chapter 7 for SRM and MDL. Chapters 12, 13 and 14 build on each other (convexity, then regularization and stability, then SGD), Chapter 15 needs Chapters 13 and 14, and Chapter 16 needs Chapter 15. Chapter 21 reuses gradient descent ideas from Chapter 14. In Part IV, Chapter 26 comes first, Chapter 27 follows it, Chapter 28 completes the proof of the Chapter 6 theorem, Chapter 29 needs Chapters 6 and 17, and Chapters 30 and 31 are best read after Chapter 7.
Know what the book does not cover. It was published in 2014, and its core theory (PAC and agnostic PAC learning, the VC-dimension, SRM and MDL, convex learning, SGD, SVM and kernels, boosting, Rademacher complexity and PAC-Bayes) has not dated. Deep learning is the gap. Chapter 20 is a single chapter on feedforward networks with sign and sigmoid units, covering expressive power, sample complexity, hardness of training and backpropagation. Convolutional networks are only mentioned in passing, and recurrent networks, ReLU units, dropout, batch normalization and attention models do not appear. Reinforcement learning is only mentioned in Section 1.3. There is no program code, only pseudocode, and no data sets, so pair it with a practical machine learning text.
Exercises appear at the end of Chapters 2 to 25, 29 and 31, and there are none in Chapters 26, 27, 28 and 30. The PDF contains no solutions; the book says a solution manual is provided on the course web site, which this page has not checked. The authors also note that this free copy is almost, but not entirely, identical to the printed book: page numbers differ but section numbers are the same, so cite sections, not pages. Their notice asks readers to link to the official page, so use the download button on this page and do not repost the file.
Used In These Programs
This book is used for Machine Learning (theory) and Statistical Learning courses in: BS Computer Science (as an advanced elective) and in MS Computer Science programs with a machine learning focus. Browse all Machine Learning books or all Computer Science books.
Who Should Read This
This book is written for first year graduate students in computer science, engineering, mathematics or statistics, and for undergraduates with a strong background, which in practice means final-year BSCS students taking a machine learning or statistical learning elective, MS students, and anyone preparing for research in machine learning. It is a good first theory text, and a useful reference for engineers who want to know why methods such as boosting, SVMs and SGD work and what sample size they need. It is not a first course in practical machine learning: it has no code, no data sets and only one chapter on neural networks, so if you want to build models first, start with a practical book and return here for the reasoning. If your probability or proof skills are rusty, Mathematics for Computer Science covers probability, counting and proofs, and Discrete Mathematics: An Open Introduction helps with proof technique. For probability and statistics worked in code, try Think Stats, and Think Bayes is a gentle companion to the Bayesian reasoning in Chapter 24.
Applicable Universities
This book is useful for students at Pakistani universities offering BS Computer Science and MS programs with a machine learning or statistical learning course, including Punjab University, Virtual University, COMSATS, FAST, UET, NUST, and other HEC-recognized institutions.
Official Copy of Understanding Machine Learning
Shai Shalev-Shwartz and Shai Ben-David offer a free copy for personal use on their book page at the Hebrew University of Jerusalem, and they ask readers to link to that page instead of reposting the file. Click below to open the official page and download the PDF. The authors’ site may not open on some networks; if it does not load, try again later or from another connection.
→ Visit Official PageFAQs
Is Understanding Machine Learning free?
Yes, as a personal copy. Shai Shalev-Shwartz and Shai Ben-David offer the PDF free on their official page. It is not an open-licence book: the copy states “This copy is for personal use only. Not for distribution. Do not post.” and asks readers to link to the authors’ page. The copyright is held by the authors and the book is published by Cambridge University Press, so use the official page and do not repost the file.
Which edition is this?
It is the first edition, published in 2014 by Cambridge University Press (ISBN 978-1-107-05713-5, hardback). The free PDF has 449 pages, and the authors note that it is “almost, but not entirely, identical to the printed version”: page numbers differ but section numbers are the same, so cite section numbers.
How many chapters and exercises does it have?
There are 31 chapters in four parts (Foundations, From Theory to Algorithms, Additional Learning Models and Advanced Theory), plus an introduction and three appendices (technical lemmas, measure concentration and linear algebra). Exercises close Chapters 2 to 25, 29 and 31; Chapters 26, 27, 28 and 30 have none. The PDF has no solutions, although the book says a solution manual is provided on the course web site.
Is it good for complete beginners?
No. The authors assume you are comfortable with basic probability, linear algebra, analysis and algorithms, and they aim the first three parts at first year graduate students, with Part IV for researchers. A strong undergraduate can manage it. Beginners should read Chapter 1, the definitions in Chapters 2 and 3, and the algorithm chapters 9, 10 and 11, skip the proofs, or start with a practical machine learning book first.
Does it cover SVMs, kernels and deep learning?
SVMs and kernels are covered in depth (Chapters 15 and 16), together with boosting, SGD, decision trees, nearest neighbor, clustering, PCA and generative models. Neural networks get one chapter (Chapter 20) on expressive power, sample complexity, hardness and backpropagation. Convolutional and recurrent networks, ReLU units, dropout and attention models are not covered, and the book has no program code.
Is it still current in 2026?
The theory is. PAC learning, the VC-dimension, SRM and MDL, convex learning, SGD, SVMs, kernels, boosting, Rademacher complexity and PAC-Bayes bounds are standard material and have not changed in substance. What dates the book is the missing deep learning practice, since it was published in 2014. Read it for the principles and use a recent text for modern neural networks.
Related Books
- Mathematics for Computer Science – Lehman, Leighton & Meyer (MIT OCW)
- Think Stats: Exploratory Data Analysis in Python – Allen B. Downey
- Think Bayes: Bayesian Statistics in Python – Allen B. Downey
- Discrete Mathematics: An Open Introduction – Oscar Levin (4th Edition)
Together, the 31 chapters give you the theory behind modern machine learning, from PAC learning and the VC-dimension to SGD, SVMs, kernels, boosting, online learning and PAC-Bayes bounds, in one rigorous book. Browse more Computer Science books for the rest of your semester.
Understanding Machine Learning: From Theory to Algorithms (first published 2014) by Shai Shalev-Shwartz (The Hebrew University of Jerusalem) and Shai Ben-David (University of Waterloo). Copyright 2014 Shai Shalev-Shwartz and Shai Ben-David, published by Cambridge University Press. This is not an open-licence book: the authors’ free copy states “This copy is for personal use only. Not for distribution. Do not post. Please link to: http://www.cs.huji.ac.il/~shais/UnderstandingMachineLearning”, and all rights remain with the authors and the publisher. Official source: https://www.cs.huji.ac.il/~shais/UnderstandingMachineLearning/ This page links to the official site and does not host or copy the book.
© Copyright Policy
Freebooks.pk is an educational resource for students in Pakistan. Textbooks and other books belong to their respective boards, authors and publishers, and all rights remain with them. If you are the copyright holder of any material on this page and want it changed or removed, please contact us or file a request under our DMCA policy. We review every request and remove reported content promptly.
