BS Data Science, MS Statistics and advanced BSCS students can use this guide to study “The Elements of Statistical Learning: Data Mining, Inference, and Prediction” (Second Edition) by Trevor Hastie, Robert Tibshirani and Jerome Friedman. The authors, all Stanford professors, offer it as a free PDF on their book page, with the permission of the publisher, Springer. The PDF is the 12th printing with corrections and a table of contents, dated January 2017, and it has 18 chapters over 764 pages.
It is a graduate-level reference, and this page says so plainly. The book covers linear regression and classification, splines and kernel smoothing, model assessment and cross-validation, the bootstrap and EM, trees, boosting, neural networks, support vector machines, nearest neighbours, clustering and principal components, random forests, graphical models and high-dimensional problems. It expects an elementary statistics course and comfort with matrices. Beginners should start with An Introduction to Statistical Learning, a shorter and gentler book by some of the same authors, and come back here for the theory.
Book Overview
| Course | Statistical Learning / Machine Learning / Data Mining |
| Degree Programs | BS Data Science, MS (Statistics, Data Science, Computer Science) |
| Level | Graduate / advanced undergraduate |
| Edition | Second Edition (Springer, 2009); the free PDF is the 12th printing with corrections and table of contents, January 2017 |
| Authors | Trevor Hastie, Robert Tibshirani and Jerome Friedman (Stanford University) |
| Publisher | Springer (Springer Series in Statistics); Springer holds the copyright and allows the authors to keep the book on the web |
| Total Chapters | 18 chapters (no declared parts), followed by references, an author index and a subject index |
| Exercises | End-of-chapter exercises in Chapters 2–18, about 200 in all; no solutions in the PDF |
| Prerequisites | At least one elementary statistics course including linear regression (the authors’ words), plus matrix algebra and probability |
| Language | English |
| Format | PDF — one file of 764 pages (about 13 MB) from the authors’ download page |
Chapter List
The book has 18 chapters and declares no parts or semesters. The blocks below follow its own chapter numbers; the references, author index and subject index at the end have no block.
Chapter 1: Introduction
Difficulty: Easy · Key topics: supervised learning, unsupervised learning, regression, classification, features, training set, spam, prostate cancer, handwritten digits, microarrays
The chapter opens with real learning problems, such as predicting a second heart attack, a stock price or a blood glucose level, and defines the basic setting: an outcome to predict, a set of features, and a training set from which a learner is built. It separates supervised from unsupervised learning and then introduces four running examples: 4601 email messages with 57 word and character frequencies, 97 prostate cancer patients, handwritten ZIP code digits and a 6830-gene microarray over 64 tumours. It closes with a reading guide for the other chapters.
Key Points:
- Supervised learning has an outcome measurement that guides the fit; unsupervised learning has only features and aims to describe how the data are organised.
- A quantitative outcome gives a regression problem and a categorical outcome gives a classification problem.
- The spam data show that errors are not equal: wrongly filtering a good email is worse than letting one spam message through.
- The prostate data predict the log of PSA level from eight clinical measurements in 97 men, a small regression problem used again in Chapters 3 and 4.
- The digit images are 16 by 16 grayscale grids, and the task allows a “don’t know” class that is sorted by hand to keep the error rate very low.
- The microarray example treats 64 tumour samples as points in a 6830-dimensional space and asks which samples and genes are alike.
Memory Tip: Supervised learning has an answer key (the outcome) and unsupervised learning does not. If you can write down the thing you want to predict, it is supervised.
Common Mistake: Reading the book as a catalogue of algorithms. The authors say they stress the concepts for judging a method, and they ask readers to read Chapters 1 to 4 and Chapter 7 first.
Important Questions:
- What is the difference between supervised and unsupervised learning? Supervised learning predicts an outcome from features using training data where the outcome is observed; unsupervised learning has no outcome and looks for structure such as clusters.
- Why are the two spam errors not equally costly? Sending a genuine email to the junk folder can lose important information, while a missed spam message is only an annoyance, so the loss function should penalise the first more.
Chapter 2: Overview of Supervised Learning
Difficulty: Medium · Key topics: least squares, k-nearest neighbours, expected prediction error, Bayes classifier, curse of dimensionality, restricted estimators, bias-variance tradeoff
The chapter fixes the vocabulary of inputs, outputs and variable types, then compares two simple predictors on a two-class simulated problem: the linear model fitted by least squares, which is stable but assumes a lot, and k-nearest neighbours, which assumes little but is noisy. Statistical decision theory follows, giving the regression function as the best prediction under squared error and the Bayes classifier under 0-1 loss. It shows why local methods fail in high dimensions, then surveys model classes and ends with the bias-variance tradeoff.
Key Points:
- Under squared error loss the best predictor is the conditional mean
f(x) = E(Y | X = x); under 0-1 loss it is the Bayes classifier, which picks the most probable class. - Least squares has low variance and possibly high bias; nearest neighbours have low bias and high variance.
- Training error of k-nearest neighbours is zero at k = 1, so it cannot be used to choose k.
- Curse of dimensionality: in ten dimensions a neighbourhood that captures 10% of uniform data must cover 80% of the range of each coordinate.
- Without restrictions, minimising the residual sum of squares has infinitely many solutions, so every learning method adds some kind of complexity restriction.
- The three families of restricted estimators are roughness penalties, kernel methods and basis-function dictionaries.
Memory Tip: Think of a dial from rigid to flexible. A straight line is the rigid end, one-nearest-neighbour is the flexible end, and every later chapter is a way of choosing a setting in between.
Common Mistake: Choosing a model because it has the smallest training error. A very flexible fit can score perfectly on the training data and still predict new data badly.
Important Questions:
- What is the curse of dimensionality? As the number of inputs grows, data become sparse and a neighbourhood containing a useful fraction of the data is no longer local, so nearest-neighbour estimates lose their accuracy.
- What is the bias-variance tradeoff? Making a model more flexible lowers its bias but raises its variance; the best test error comes from a balance chosen with a complexity parameter.
Chapter 3: Linear Methods for Regression
Difficulty: Medium · Key topics: least squares, Gauss-Markov theorem, subset selection, ridge regression, lasso, least angle regression, principal components regression, partial least squares
The chapter starts with the linear regression model, least squares, the F statistic and the Gauss-Markov theorem, and shows how multiple regression is built from univariate regressions by successive orthogonalisation. Because least squares often has low bias but high variance, it then presents subset selection, shrinkage by ridge regression and the lasso, and methods using derived directions such as principal components regression and partial least squares. The prostate data run through all of them. Least angle regression and the later section on lasso path algorithms complete the chapter.
Key Points:
- Gauss-Markov: among all linear unbiased estimators, least squares has the smallest variance, but a biased estimator can still have lower total error.
- Ridge regression penalises the squared size of the coefficients and shrinks them all; its effective degrees of freedom
df(lambda)decrease as the penalty grows. - The lasso uses an absolute-value penalty, which can set coefficients exactly to zero and so selects variables.
- Least angle regression computes the whole lasso path at about the cost of one least squares fit.
- Principal components regression ignores the response when building its directions; partial least squares uses it.
- Predictors should be standardised before ridge or lasso, and the intercept is not penalised.
- Later sections add the elastic net, the Dantzig selector and the grouped lasso for predictors that come in groups.
Memory Tip: Ridge shrinks every coefficient a little; the lasso shrinks and also drops some. Picture the lasso constraint as a diamond whose corners sit on the axes, so solutions land on a corner where a coefficient is zero.
Common Mistake: Forgetting to standardise the predictors before ridge or lasso. The penalty depends on the scale of each variable, so unscaled inputs are penalised unfairly.
Important Questions:
- How does the lasso differ from ridge regression? Ridge uses a squared penalty and keeps all variables with smaller coefficients; the lasso uses an absolute-value penalty and produces sparse models with some coefficients exactly zero.
- What does the Gauss-Markov theorem say? Least squares estimates have the smallest variance among all linear unbiased estimates of the coefficients.
Chapter 4: Linear Methods for Classification
Difficulty: Medium · Key topics: indicator matrix regression, linear discriminant analysis, quadratic discriminant analysis, regularized discriminant analysis, logistic regression, separating hyperplanes, perceptron
The chapter divides the input space into regions with linear decision boundaries. It begins with linear regression on an indicator matrix and its masking problem, then develops linear and quadratic discriminant analysis from Gaussian class densities, including Friedman’s regularized compromise and reduced-rank discriminant plots. Logistic regression models the class probabilities directly and is fitted by maximum likelihood, with the South African heart disease data as the example and an L1 penalty version. The chapter closes by comparing logistic regression with LDA and covering the perceptron and optimal separating hyperplanes.
Key Points:
- LDA assumes Gaussian classes with a common covariance matrix, which makes the decision boundaries linear; allowing separate covariances gives QDA with quadratic boundaries.
- Regularized discriminant analysis shrinks the separate covariances toward a common one, in the same spirit as ridge regression.
- Logistic regression models the log-odds as linear in the inputs and is fitted by maximum likelihood with iteratively reweighted least squares.
- With three or more classes, regression on an indicator matrix can mask a middle class, which LDA and logistic regression avoid.
- The perceptron algorithm finds a separating hyperplane when one exists, but it is not unique and may not converge when classes overlap.
- The optimal separating hyperplane maximises the margin to the closest point of either class and is the starting point for support vector machines.
Memory Tip: LDA models how the inputs look inside each class; logistic regression models how the class depends on the inputs. The first is generative and the second is discriminative.
Common Mistake: Treating logistic regression coefficients as changes in probability. They are changes in the log-odds, so the effect on probability depends on where you are on the curve.
Important Questions:
- When does LDA give a linear decision boundary? When each class density is Gaussian and all classes share the same covariance matrix, the log-posterior odds are linear in x.
- What is the difference between LDA and logistic regression? Both give linear log-odds, but LDA fits them from a Gaussian model of the inputs while logistic regression fits the conditional probabilities directly, making fewer assumptions.
Chapter 5: Basis Expansions and Regularization
Difficulty: Hard · Key topics: basis expansion, piecewise polynomials, natural cubic splines, smoothing splines, effective degrees of freedom, multidimensional splines, reproducing kernel Hilbert spaces, wavelets
The chapter moves beyond linear models by replacing the inputs with a set of basis functions and fitting a model that is linear in those new features. It builds piecewise polynomials, regression splines and natural cubic splines, with the heart disease and phoneme recognition examples. Smoothing splines avoid choosing knots by using every data point as a knot and controlling roughness with a penalty. It covers choosing the smoothing parameter, nonparametric logistic regression, tensor-product splines, reproducing kernel Hilbert spaces, and wavelet smoothing for signals on a regular grid.
Key Points:
- A basis expansion
f(x) = sum of beta_m h_m(x)is still a linear model in the new features, so least squares machinery still applies. - Natural cubic splines are forced to be linear beyond the boundary knots, which reduces the erratic behaviour of polynomials near the edges.
- A smoothing spline minimises the residual sum of squares plus lambda times the integrated squared second derivative; its solution is a natural cubic spline with knots at the data points.
- The effective degrees of freedom is the trace of the smoother matrix, which lets you specify the smoothing by df instead of lambda.
- The smoothing parameter can be chosen by cross-validation or by fixing the degrees of freedom.
- The RKHS section (marked as technical) shows that many penalised function-fitting problems have finite-dimensional solutions through a kernel.
- Wavelets use a sparse, localised basis, and soft thresholding of wavelet coefficients is the adaptive filtering step.
Memory Tip: Smoothing splines trade a knot-choosing problem for a single dial. Large lambda gives a straight line, and lambda near zero gives a curve that passes through every point.
Common Mistake: Treating the number of knots as the model complexity of a smoothing spline. Its complexity is the effective degrees of freedom, which depends on lambda.
Important Questions:
- What is a smoothing spline? The function that minimises the residual sum of squares plus a roughness penalty on its second derivative; it is a natural cubic spline with a knot at every distinct input value.
- Why use natural cubic splines instead of ordinary cubic splines? The extra boundary constraints make the fit linear outside the outer knots, which lowers variance where there is little data.
Chapter 6: Kernel Smoothing Methods
Difficulty: Medium · Key topics: kernel smoother, Nadaraya-Watson, local linear regression, bandwidth, local likelihood, kernel density estimation, naive Bayes, radial basis functions, mixture models
The chapter describes regression that fits a different simple model at each query point, using a kernel to weight nearby observations. It begins with one-dimensional smoothers, shows the boundary bias of the weighted average and how local linear and local polynomial fits correct it, and discusses choosing the kernel width. Local regression is then extended to several dimensions and to structured forms. Local likelihood, kernel density estimation, kernel density classification and the naive Bayes classifier follow, with radial basis functions and Gaussian mixtures at the end.
Key Points:
- A kernel smoother takes a weighted average of the outputs near x0, with weights that fall smoothly with distance, which fixes the jagged fit of plain k-nearest neighbours.
- Local linear regression removes the first-order boundary bias of the weighted average; local quadratic fits help in regions with curvature.
- The width lambda controls the tradeoff: a narrow window has low bias and high variance, and a wide window the reverse.
- Kernel and local regression lose their power in high dimensions, so structured kernels or additive structure are needed.
- Naive Bayes assumes the features are independent within each class, which makes density estimation easy when p is large.
- These are memory-based methods: the model is the training data, and the fitting happens at prediction time.
Memory Tip: A kernel smoother is a moving average with soft edges. The width is the only real decision, just like the window in a moving average.
Common Mistake: Using a kernel with a fixed metric width in regions where data are sparse. The window then contains very few points and the estimate becomes noisy.
Important Questions:
- Why is local linear regression better than a kernel-weighted average near the boundary? The weighted average is biased there because the window is lopsided; fitting a local line corrects the bias to first order.
- What does the naive Bayes classifier assume? That the features are conditionally independent given the class, so the class density is a product of one-dimensional densities.
Chapter 7: Model Assessment and Selection
Difficulty: Medium · Key topics: generalization error, bias-variance decomposition, optimism, AIC, BIC, effective parameters, VC dimension, cross-validation, bootstrap
The chapter explains how to judge a fitted model by its performance on independent test data. It separates bias, variance and model complexity, derives the bias-variance decomposition, and shows that training error is an optimistic estimate of test error. It then covers estimates of in-sample error such as Cp, AIC and BIC, the effective number of parameters, minimum description length and the Vapnik-Chervonenkis dimension. Cross-validation and the bootstrap, including the .632+ estimator, are presented as direct estimates, along with the wrong and right way to do cross-validation.
Key Points:
- Expected prediction error at a point splits into irreducible noise, squared bias and variance.
- Training error falls as complexity grows, so it is an optimistic estimate; the gap is called optimism.
- AIC and BIC both penalise the log-likelihood by model size, with BIC penalising more as the sample grows.
- Five- or tenfold cross-validation is recommended as a good compromise between the bias of small folds and the variance of leave-one-out.
- Wrong way: screening predictors using all the labels and then cross-validating; any step that uses the outcome must happen inside every fold.
- The bootstrap estimates prediction error by refitting on resamples, and the .632+ estimator corrects its bias in overfit situations.
- The chapter separates error conditional on one training set from expected error over training sets.
Memory Tip: Split the data three ways in your head: train to fit, validation to choose, test to report. Touching the test set while choosing means it is no longer a test.
Common Mistake: Selecting the best predictors on the full dataset and then cross-validating the classifier. This leaks information and can give impressive error rates on pure noise.
Important Questions:
- What is the right way to cross-validate when features are screened first? Repeat the screening step inside each fold, using only that fold’s training part, so the held-out part never influences which features are chosen.
- How do AIC and BIC differ? Both penalise model size, but BIC’s penalty grows with the logarithm of the sample size, so it favours simpler models and is consistent when a true model is in the candidate set.
Chapter 8: Model Inference and Averaging
Difficulty: Hard · Key topics: maximum likelihood, bootstrap, Bayesian inference, EM algorithm, MCMC, Gibbs sampling, bagging, stacking, bumping
The chapter looks at fitting as maximum likelihood and shows that least squares and cross-entropy are special cases. It explains the bootstrap, both nonparametric and parametric, through a smoothing example and its relation to maximum likelihood, then Bayesian inference and the link between bootstrap and posterior distributions. The EM algorithm is developed on a two-component mixture and in general, followed by MCMC and Gibbs sampling. The last sections use the bootstrap to improve predictions: bagging, model averaging and stacking, and bumping.
Key Points:
- Squared error with Gaussian noise and cross-entropy for classification are both maximum likelihood fits of a probability model.
- The parametric bootstrap agrees with maximum likelihood theory, while the nonparametric bootstrap needs no distributional assumption.
- A Bayesian analysis combines a sampling model with a prior to give a posterior; with a noninformative prior it resembles the bootstrap distribution.
- The EM algorithm alternates an expectation step for latent variables with a maximisation step, and each iteration cannot decrease the likelihood.
- Bagging averages predictions over bootstrap samples and reduces the variance of unstable procedures such as trees.
- Stacking learns weights for combining models using cross-validated predictions; bumping picks the best of several bootstrap fits instead of averaging.
Memory Tip: EM is two steps on repeat: guess the hidden labels softly (E step), then refit the parameters as if those guesses were real (M step).
Common Mistake: Expecting bagging to help every model. It reduces variance, so it helps unstable learners like trees but does little for a stable linear fit.
Important Questions:
- What problem does the EM algorithm solve? It finds maximum likelihood estimates when the likelihood is hard to maximise directly because of latent variables or missing data, such as in a Gaussian mixture.
- Why does bagging reduce variance? Averaging the predictions of many models fitted to bootstrap samples smooths out the instability of each single fit while leaving its bias about the same.
Chapter 9: Additive Models, Trees, and Related Methods
Difficulty: Medium · Key topics: generalized additive models, backfitting, regression trees, classification trees, pruning, PRIM, MARS, hierarchical mixtures of experts, missing data
The chapter begins the structured methods for supervised learning, each of which assumes a particular form for the unknown function to sidestep the curse of dimensionality. It covers generalized additive models fitted by backfitting with smoothers, and tree-based methods: how a regression or classification tree chooses splitting variables and split points, how cost-complexity pruning picks a tree size, and the spam example. It then describes PRIM bump hunting, MARS, hierarchical mixtures of experts, the handling of missing data and the computing cost.
Key Points:
- An additive model
f(X) = alpha + f1(X1) + ... + fp(Xp)keeps the interpretability of a linear model while letting each effect be nonlinear. - Backfitting cycles through the variables, smoothing the partial residuals for each, until the functions stop changing.
- A tree splits the feature space into rectangles using greedy binary splits and fits a constant in each region.
- Cost-complexity pruning grows a large tree and then collapses nodes; the penalty parameter is chosen by cross-validation.
- Trees handle mixed data types and missing values well but are unstable: a small change in the data can change the whole tree.
- MARS builds a model from piecewise linear basis functions and their products, and can be seen as a generalisation of stepwise linear regression.
- PRIM looks for boxes of the input space where the response average is high, instead of splitting the entire space.
Memory Tip: Trees ask a series of yes or no questions about the inputs, like the game twenty questions, and the answer at the end of the path is an average or a majority vote.
Common Mistake: Trusting a single large tree. Without pruning it fits noise, and even a pruned tree can change a lot with a small change to the training data.
Important Questions:
- How is a regression tree grown? At each node it searches over all variables and split points for the split that most reduces the residual sum of squares, then repeats on each child until a minimum node size is reached.
- What is backfitting? An iterative procedure for additive models that repeatedly updates each component function by smoothing the residuals left by all the other components.
Chapter 10: Boosting and Additive Trees
Difficulty: Hard · Key topics: AdaBoost, forward stagewise modeling, exponential loss, loss functions, gradient boosting, shrinkage, subsampling, variable importance, partial dependence
The chapter shows that boosting is not mysterious: it fits an additive expansion of simple base learners by forward stagewise modeling. AdaBoost is derived as the case of exponential loss, which leads to a comparison of loss functions and their robustness. The authors describe off-the-shelf procedures for data mining and why trees are the best fit for that role, then develop boosted trees and gradient boosting as numerical optimisation in function space. They add tree size, shrinkage and subsampling as regularisation, and interpretation tools, with California housing and other examples.
Key Points:
- AdaBoost reweights the training points after each round, giving more weight to those misclassified, and combines the weak classifiers by a weighted vote.
- AdaBoost is equivalent to forward stagewise additive modeling with exponential loss; binomial deviance is a more robust alternative.
- Gradient boosting fits each new tree to the negative gradient of the loss, so any differentiable loss can be used.
- Shrinkage multiplies each new tree by a learning rate between 0 and 1, and small values with more iterations usually give better test error.
- Subsampling a fraction of the training data at each step reduces variance and cost, in the spirit of bagging.
- Tree size is a tuning parameter: the authors’ experience is that 4 to 8 terminal nodes usually work well, since tree size controls the order of interactions.
- Relative importance scores and partial dependence plots help to interpret an ensemble that has no single tree to read.
Memory Tip: Boosting is golf with a tree for each shot: each new tree aims at the distance still left to the hole, which is the current residual or gradient.
Common Mistake: Running gradient boosting with no learning rate and too many iterations. The training error keeps falling while the test error starts to rise.
Important Questions:
- What loss function does AdaBoost minimise? The exponential loss
exp(-y f(x)), which the chapter shows by fitting an additive model with forward stagewise updates. - What is gradient boosting? A method that builds an additive model of trees by fitting each new tree to the negative gradient of the loss at the current model, which allows many loss functions.
Chapter 11: Neural Networks
Difficulty: Medium · Key topics: projection pursuit regression, single hidden layer network, back-propagation, weight decay, starting values, overfitting, ZIP code data, Bayesian neural nets
The chapter presents the vanilla neural network, a single hidden layer back-propagation network, as a two-stage model that builds derived features from linear combinations of the inputs and then models the output as a function of those features. It starts with projection pursuit regression, which uses the same idea. The authors explain how weights are fitted by back-propagation and gradient descent, then give practical advice on starting values, overfitting, input scaling, hidden units and multiple minima. Examples are simulated data and ZIP codes, and the final section covers Bayesian networks.
Key Points:
- Derived features
Z_m = sigma(alpha_m0 + alpha_m' X)pass through a sigmoid; the output is then a function of these features, which makes the model nonlinear. - With weights near zero the sigmoid is nearly linear, so a network started at small random weights begins as an almost linear model.
- Back-propagation is gradient descent with the chain rule, and the error function is nonconvex with many local minima.
- Weight decay penalises large weights, in the same way as ridge regression, and early stopping is a related way to avoid overfitting.
- Inputs should be standardised, and it is usually better to have too many hidden units than too few when weight decay is used.
- Averaging several networks from different random starts reduces the instability from multiple minima.
- This is a 2009 treatment of one hidden layer; it does not cover deep or convolutional networks.
Memory Tip: A hidden layer is a set of learned features: each hidden unit is a logistic regression on the inputs, and the output layer then combines those features.
Common Mistake: Starting all the weights at exactly zero. The gradients are then zero and the symmetry is perfect, so the algorithm never moves.
Important Questions:
- What is back-propagation? An algorithm that computes the gradient of the error with respect to all weights by passing errors backward through the network layer by layer, used with gradient descent to fit the weights.
- How can overfitting be controlled in a neural network? By adding weight decay, stopping the training early using validation error, limiting the number of hidden units, or averaging several networks.
Chapter 12: Support Vector Machines and Flexible Discriminants
Difficulty: Hard · Key topics: support vector classifier, kernels, SVM, hinge loss, regularization path, flexible discriminant analysis, penalized discriminant analysis, mixture discriminant analysis
The chapter generalises the optimal separating hyperplane of Chapter 4. The support vector classifier handles overlapping classes with a cost parameter and a soft margin and is computed by quadratic programming. Support vector machines enlarge the feature space with basis expansions and use kernels so only inner products are needed. The authors show the SVM as a penalisation method with hinge loss, discuss its link to reproducing kernels, a path algorithm and regression. The rest of the chapter covers flexible, penalized and mixture discriminant analysis.
Key Points:
- The soft-margin classifier allows some points inside the margin, with cost parameter C controlling how strongly they are punished.
- The solution depends only on the support vectors, the points on or inside the margin or misclassified.
- The kernel trick computes inner products in a very large feature space without building it; popular kernels are polynomial, radial basis and neural network.
- The SVM equals minimising hinge loss plus a squared-norm penalty, the familiar loss plus penalty form.
- Large C fits the training data hard and can overfit; small C gives a wider margin and a smoother boundary.
- Flexible discriminant analysis does LDA through regression on optimally scored classes, so any regression method can replace linear regression.
- Mixture discriminant analysis models each class by a mixture of Gaussians, allowing several prototypes per class.
Memory Tip: Only the support vectors matter. Remove every other point and the SVM boundary does not move.
Common Mistake: Leaving the cost C and the kernel width at their defaults. Both strongly affect test error and should be tuned by cross-validation.
Important Questions:
- What is the kernel trick? The SVM solution depends on the data only through inner products, so a kernel function can replace the inner product of expanded features and give a nonlinear boundary without computing the expansion.
- What are support vectors? The training points that lie on the margin, inside it or on the wrong side; they alone determine the fitted decision boundary.
Chapter 13: Prototype Methods and Nearest-Neighbors
Difficulty: Medium · Key topics: K-means, learning vector quantization, Gaussian mixtures, k-nearest-neighbor classifiers, tangent distance, adaptive nearest neighbors, dimension reduction
The chapter covers simple, nearly model-free classification and pattern recognition methods that are not meant to explain the data but often predict well. Prototype methods represent each class by a set of points in feature space: K-means clusters, learning vector quantization, which moves prototypes toward the decision boundaries, and Gaussian mixtures. Next come k-nearest-neighbour classifiers, with simulated and satellite image examples, and invariant metrics such as tangent distance for handwritten digits. The chapter ends with adaptive nearest-neighbour methods and dimension reduction for high dimensions.
Key Points:
- A prototype method classifies a new point to the class of its closest prototype, and prototypes may be far fewer than training points.
- Used for classification, K-means is run separately within each class and the resulting centres become the labelled prototypes.
- Learning vector quantization is an online algorithm that pulls prototypes toward same-class points and pushes them away from other classes.
- A one-nearest-neighbour rule has an asymptotic error rate of at most twice the Bayes rate.
- Tangent distance builds invariance to small transformations, such as rotation or shift of a digit, into the metric.
- In high dimensions, neighbours can be far away, so adaptive methods such as DANN stretch the neighbourhood along directions where the class probabilities do not change.
- Prediction needs the whole training set, so nearest-neighbour rules cost memory and time at run time.
Memory Tip: k-NN follows the saying that you are like your neighbours. Small k listens to a few close voices and is noisy; large k listens to a crowd and is smooth.
Common Mistake: Running nearest neighbours on features with different units. Distance is dominated by the largest-scale variable unless the inputs are standardised.
Important Questions:
- How does the choice of k affect a k-nearest-neighbour classifier? Small k gives low bias and high variance with jagged boundaries; large k gives smoother boundaries with more bias, and k is chosen by cross-validation.
- What is learning vector quantization? An online prototype method that moves each prototype toward training points of its own class and away from points of other classes, placing prototypes near the decision boundaries.
Chapter 14: Unsupervised Learning
Difficulty: Medium · Key topics: association rules, Apriori, cluster analysis, K-means, hierarchical clustering, self-organizing maps, principal components, spectral clustering, NMF, ICA, multidimensional scaling, PageRank
This is the longest chapter. It turns from prediction to describing structure when there is no outcome. Association rules and market basket analysis find frequent item sets with the Apriori algorithm. Cluster analysis covers dissimilarity measures, K-means, Gaussian mixtures, K-medoids, practical issues such as choosing the number of clusters, and hierarchical clustering. Then come self-organizing maps, principal components, curves and surfaces, spectral clustering, kernel and sparse PCA, non-negative matrix factorization, ICA, multidimensional scaling, nonlinear dimension reduction, and Google PageRank.
Key Points:
- An association rule is described by its support (how often the items occur together) and its confidence (how often the consequent follows the antecedent).
- Apriori is feasible for large databases because every subset of a frequent item set must also be frequent.
- K-means alternates between assigning points to the closest centre and moving each centre to the mean of its points; it finds a local minimum, so use several starts.
- Hierarchical clustering builds a dendrogram, with single, complete or average linkage defining the distance between groups.
- Principal components give the best linear approximation of each rank to the data; the first component is the direction of largest variance.
- Non-negative matrix factorization approximates the data by non-negative parts, which often gives more interpretable features than PCA.
- PageRank is the stationary distribution of a random walk on the web graph, found with the power method.
Memory Tip: For clustering, ask two questions in order: what does close mean (the dissimilarity), and how many groups (K). Everything else is a method for answering them.
Common Mistake: Treating the clusters found as real groups in nature. K-means will always return K clusters, even in data with no cluster structure at all.
Important Questions:
- What are support and confidence in association rules? Support is the fraction of baskets containing both the antecedent and the consequent; confidence is the fraction of baskets with the antecedent that also contain the consequent.
- How does K-means work? It picks K initial centres, assigns every point to the nearest centre, recomputes each centre as the mean of its points, and repeats until the assignments stop changing.
Chapter 15: Random Forests
Difficulty: Medium · Key topics: bagging, random forest, random feature selection, out-of-bag samples, variable importance, proximity plots, de-correlation, bias
The chapter builds on bagging, which averages many noisy but nearly unbiased trees to cut variance. A random forest adds one more step: at each split only a random subset of the inputs is considered, which de-correlates the trees and lets the average reduce variance further. The authors give the algorithm and the usual defaults for classification and regression, then the details: out-of-bag samples for free error estimates, variable importance, proximity plots and behaviour with many noise variables. The last section analyses variance, bias and the link to adaptive nearest neighbours.
Key Points:
- At each split a random forest picks m of the p inputs at random and splits on the best of those, instead of searching all p.
- The recommended defaults are m equal to the square root of p with a minimum node size of one for classification, and m equal to p divided by 3 with a minimum node size of five for regression.
- Each tree is fitted to a bootstrap sample, so about a third of the observations are out of bag for it and can be used to estimate the test error without a separate validation set.
- Variable importance can be computed from the split improvements or by permuting a variable in the out-of-bag samples.
- Averaging B trees reduces variance when the trees are less correlated; smaller m lowers the correlation but raises the variance of each tree.
- The bias of a forest is about the bias of one of its trees, so adding more trees does not cause overfitting, although fully grown trees can still overfit the data a little.
- With many noise variables and small m, a forest can perform poorly because relevant variables are rarely available at a split.
Memory Tip: Bagging averages trees that look alike; a random forest forces them to look different by hiding some inputs at each split.
Common Mistake: Keeping the default m for every dataset. The book shows m = 6 beating the default on a spam-style example, so treat m as a tuning parameter.
Important Questions:
- How does a random forest differ from bagging? Both average trees grown on bootstrap samples, but a forest also restricts each split to a random subset of the predictors, which reduces the correlation between trees.
- What are out-of-bag samples? For each tree, the observations left out of its bootstrap sample; predicting them with that tree gives an honest error estimate without cross-validation.
Chapter 16: Ensemble Learning
Difficulty: Hard · Key topics: ensembles, regularization paths, penalized regression, bet on sparsity, margins, importance sampled learning ensembles, rule ensembles
The chapter takes the idea of combining many simple base models and asks why it works. It treats the sequence of models from a boosting algorithm like a path of solutions from a penalised regression on a huge dictionary of trees. Forward stagewise with shrinkage behaves like the lasso, which motivates the bet on sparsity principle. It then discusses why boosting is slow to overfit in terms of margins. The final section shows how to learn a good ensemble with post-processing, using importance sampled learning ensembles and rule ensembles.
Key Points:
- An ensemble is a linear combination of base learners, usually trees, and learning it has two steps: build the dictionary, then choose coefficients.
- Boosting with shrinkage follows a path that closely tracks the lasso path on the dictionary of all trees.
- Bet on sparsity: use a procedure that does well in sparse problems, since no procedure does well in dense ones, so little is lost by betting on sparsity.
- The lasso penalty suits the case where only a few basis functions matter, and ridge penalties suit the dense case.
- Post-processing a tree ensemble with a lasso fit can give a smaller model with similar or better accuracy.
- An importance sampled learning ensemble (ISLE) grows trees on subsamples and then selects and weights them with a penalised fit.
- Rule ensembles turn the terminal nodes and paths of trees into simple rules that are easier to read.
Memory Tip: Gradient boosting with a small step size is a slow walk along a regularization path. Stopping early is the same as picking a penalty level.
Common Mistake: Believing that boosting never overfits. The book says it is slow to overfit, not immune, and the number of iterations still needs to be chosen.
Important Questions:
- What is the bet on sparsity principle? Use methods like the lasso that work well when few features matter; in the dense case nothing works well anyway, so little is lost by assuming sparsity.
- How is boosting related to the lasso? Forward stagewise fitting with a small shrinkage factor traces a path of solutions that is close to the lasso path on the dictionary of all possible trees.
Chapter 17: Undirected Graphical Models
Difficulty: Hard · Key topics: Markov graphs, conditional independence, Gaussian graphical models, graphical lasso, Ising model, hidden nodes, restricted Boltzmann machines
This chapter is one of the four new chapters of the second edition, and the authors say it is not a full treatment of graphical models: directed models are left out for lack of space. It starts with graphs whose vertices are random variables and whose missing edges mean conditional independence. For continuous variables it uses Gaussian models, where zeros in the inverse covariance matrix give the missing edges, and estimates the graph with the lasso and the graphical lasso algorithm. For discrete variables it covers binary pairwise Markov networks (Ising models), hidden nodes and restricted Boltzmann machines.
Key Points:
- In a Markov graph, two variables with no edge between them are conditionally independent given all the others.
- For a Gaussian model, a zero entry in the inverse covariance matrix means no edge between those two variables.
- Adding an L1 penalty to the Gaussian log-likelihood gives a sparse estimate of the inverse covariance, computed by the graphical lasso algorithm.
- A binary pairwise Markov network is the Ising model of statistical physics, and its normalising constant is costly to compute.
- Hidden nodes make a discrete model richer, but they make the likelihood harder to maximise.
- A restricted Boltzmann machine has one visible and one hidden layer with connections only between layers, which makes inference about the hidden units simple.
Memory Tip: Draw a line only when two variables still depend on each other after the rest are known. A missing line is a statement about conditional independence, not about plain correlation.
Common Mistake: Reading edges in a graphical model as the same thing as correlations. Two variables can be strongly correlated and have no edge if a third variable explains the link.
Important Questions:
- What does a missing edge mean in an undirected graphical model? The two variables are conditionally independent given all the other variables in the graph.
- How does the graphical lasso estimate a graph? It maximises the Gaussian log-likelihood with an L1 penalty on the inverse covariance matrix, which sets many entries to zero and so removes edges.
Chapter 18: High-Dimensional Problems: p >> N
Difficulty: Hard · Key topics: p much larger than N, diagonal LDA, nearest shrunken centroids, quadratic regularization, L1 regularization, fused lasso, string kernels, supervised principal components, false discovery rate
The final chapter treats problems where the number of features is far larger than the number of observations, as in genomics, proteomics and document classification. It starts with diagonal LDA and nearest shrunken centroids on microarray data, then linear classifiers with quadratic regularization (regularized discriminant analysis, logistic regression, the support vector classifier) and with L1 regularization, including the fused lasso for ordered features. It continues with classification from a proximity matrix by string kernels, supervised principal components, and the multiple-testing problem with the false discovery rate.
Key Points:
- When p is much larger than N, the classes are usually separable by a hyperplane, so unregularized fits overfit and regularization is essential.
- Nearest shrunken centroids shrinks class centroids toward the overall centroid and drops features whose class differences shrink to zero.
- Quadratic penalties keep all features, while L1 penalties select a small set, which matters when scientists want a short list of genes.
- Computation with p much larger than N can use the N by N matrix of inner products instead of the p by p matrix.
- String kernels let a classifier work on protein sequences without defining a feature vector for each protein.
- The Benjamini-Hochberg procedure controls the false discovery rate, the expected proportion of false positives among the features called significant.
- Cross-validation must include any feature screening step, or the error estimate will be far too optimistic.
Memory Tip: With thousands of features and dozens of samples, almost any feature can look important by chance. Every method in this chapter is a way of controlling that chance.
Common Mistake: Calling the 100 features with the smallest p-values significant. With thousands of tests many of them will be false positives unless the false discovery rate is controlled.
Important Questions:
- What is the false discovery rate? The expected proportion of false positives among all the hypotheses declared significant; the Benjamini-Hochberg procedure keeps it below a chosen level.
- Why is regularization needed when p is much larger than N? With more features than observations, the training data can be fitted perfectly in many ways, so a penalty is needed to pick a stable solution that generalises.
How to Study This Book
The free PDF is the 12th printing with corrections (January 2017) of the Second Edition, 764 pages including the table of contents, with 18 chapters and no declared parts. It is a graduate-level reference, not a first textbook. The authors expect at least one elementary statistics course that includes linear regression, and in practice you also need linear algebra, basic probability and comfort with calculus, because matrix notation and maximum likelihood appear from Chapter 2 onward. If you are new to machine learning, start with a gentler book such as An Introduction to Statistical Learning by some of the same authors, then return here for the theory.
The book gives its own reading order. Read Chapters 1 to 4 in sequence, treat Chapter 7 on model assessment as mandatory because every later method depends on it, and then read the rest in order or sample by interest. The preface adds that Chapters 15 and 16 follow naturally from Chapter 10, so read boosting, random forests and ensembles together. Sections marked with the book’s technical symbol can be skipped on a first pass without losing the thread; one example is the reproducing kernel material in Chapter 5, which says of itself that it can be skipped by the disinterested or intimidated reader.
For a first course in statistical learning, this path covers the core: Chapter 2 for bias, variance and the curse of dimensionality, Sections 3.1 to 3.4 for least squares, ridge and the lasso, Sections 4.1 to 4.4 for LDA and logistic regression, Chapter 7 for cross-validation and the bootstrap, Section 9.2 for trees, Sections 10.1 to 10.4 and 10.9 to 10.12 for boosting, Chapter 15 for random forests and Sections 12.1 to 12.3 for support vector machines. A second course can then add the smoothing and kernel chapters (5 and 6), Chapter 8 on EM and MCMC, Chapter 14 on unsupervised learning and the graphical models and high-dimensional chapters (17 and 18).
Some chapters suit specific courses. For data mining, read Chapter 14 (association rules, clustering, PCA), Section 10.7 on off-the-shelf procedures and Chapter 13 on nearest neighbours. For statistics students interested in inference, Chapter 8 and the bias-variance material in Chapter 7 are central. For students working with genomic or text data, Chapter 18 is the one to read, along with Section 7.10.2 on the wrong and right way to cross-validate. Chapter 1 is short and gives the four example datasets that return throughout the book, so it is worth reading before anything else.
The book has about 200 exercises at the end of Chapters 2 to 18, but the PDF contains no solutions. Many ask you to derive a result or to reproduce a figure, and some use data from the book website. The authors taught with R and S-PLUS, and the book contains no code, so plan to work through the ideas in your own software, for example by fitting ridge, lasso, trees, boosting and random forests on a dataset of your own and comparing test errors by cross-validation. That practice is where the book becomes useful.
Know what the book does not cover. It was written in 2008 and updated through printings, so the neural network chapter describes one hidden layer only, with no deep learning, convolutional or sequence models. It does not teach modern boosting software, causal inference, reinforcement learning or large language models, and it uses relatively small datasets. The core ideas of regularization, the bias-variance tradeoff, cross-validation, trees, boosting and random forests, kernels and sparsity have aged well and are still the language of modern machine learning. A few pages in Chapter 18 on microarrays also read as a snapshot of the late 2000s.
Used In These Programs
This book is used for Statistical Learning, Machine Learning and Data Mining courses in: BS Data Science, and as advanced reading for BS Computer Science, BS Statistics and MS students. Browse all Machine Learning books or all Computer Science books.
Who Should Read This
This book is written for graduate students and strong advanced undergraduates in statistics, data science and computer science who want to understand why learning methods work, not only how to call them. It suits an MS course in statistical learning, a second course in machine learning after a gentler text, or a reference shelf for researchers who need the derivation behind the lasso, boosting, random forests or support vector machines. It is not a book for someone who has not met regression and matrix notation, and it is not a coding tutorial. If probability and linear algebra are rusty, Mathematics for Computer Science and Discrete Mathematics: An Open Introduction help with proofs and counting. For hands-on practice with data, Think Stats teaches exploratory analysis and estimation in Python, and Think Bayes gives the Bayesian view that Chapter 8 only sketches.
Applicable Universities
This book is useful for students at Pakistani universities offering BS Data Science, BS Computer Science, BS Statistics and MS programs with a statistical learning, machine learning or data mining course, including Punjab University, Virtual University, COMSATS, FAST, UET, NUST, and other HEC-recognized institutions.
Official Copy of Elements of Statistical Learning
Hastie, Tibshirani and Friedman offer the book as a free PDF from their official page, with Springer’s permission. Click below to open the download page and get the 12th printing (January 2017).
→ Visit Official PageFAQs
Is The Elements of Statistical Learning free?
Yes, to read and download. The authors’ page offers the PDF and says that Springer Science+Business Media, which holds the copyright, has agreed to let them keep the book available on the web. It is not an open-licence book, so use the official page instead of reposting the file, and buy the printed book from Springer if you want a hard copy.
Which edition is this?
The Second Edition, published by Springer in 2009 (the preface is dated August 2008). The free PDF is the 12th printing with corrections and a table of contents, dated 13 January 2017. The second edition added four chapters to the first: random forests, ensemble learning, undirected graphical models and high-dimensional problems.
How many chapters and exercises does it have?
It has 18 chapters and no declared parts. Chapters 2 to 18 end with exercises, about 200 in total, and most chapters also end with Bibliographic Notes. The PDF has 764 pages including the contents, references and indexes, and it contains no solutions to the exercises.
Is it good for complete beginners?
No. It is a graduate-level reference that assumes an elementary statistics course including regression, plus matrix algebra and probability. Beginners should start with An Introduction to Statistical Learning, a shorter book by some of the same authors with labs in R, and then use this book for the full derivations. Chapters 1 to 4 and Chapter 7 are the best place to begin.
Does it cover deep learning, XGBoost or Python code?
No. The neural network chapter (Chapter 11) covers a single hidden layer network from 2009, so there are no convolutional or recurrent networks, and the book contains no code at all; the authors used R and S-PLUS in their courses. It does cover gradient boosting, random forests and support vector machines in depth, which are the ideas behind many modern tools.
Is it still current in 2026?
The core is: regularization and the lasso, the bias-variance tradeoff, cross-validation, trees, boosting, random forests, kernels and sparsity are still taught as written. The gaps are deep learning, modern boosting software, causal inference and very large data. The text dates from 2008 and the PDF printing from January 2017, so pair it with newer material for neural networks.
Related Books
- Think Stats: Exploratory Data Analysis in Python
- Think Bayes: Bayesian Statistics in Python
- Mathematics for Computer Science – Lehman, Leighton & Meyer (MIT OCW)
- Discrete Mathematics: An Open Introduction – Oscar Levin (4th Edition)
This book gives you the reasoning behind the methods that modern machine learning is built on, from the lasso and cross-validation to boosting, random forests and support vector machines, in one free PDF. Browse more Computer Science books for the rest of your semester.
The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Second Edition by Trevor Hastie, Robert Tibshirani and Jerome Friedman, Springer Series in Statistics, Springer, 2009. The free PDF is the 12th printing with corrections (January 2017). Copyright is held by Springer Science+Business Media, LLC, which has allowed the authors to keep the book available on the web; no open licence applies. Official source: https://hastie.su.domains/ElemStatLearn/. 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.
