BS Data Science and BSCS students can read “Data Mining and Machine Learning: Fundamental Concepts and Algorithms” by Mohammed J. Zaki and Wagner Meira Jr. free on the authors’ companion website. This page covers the Second Edition (Cambridge University Press, March 2020), which adds a whole new part on regression, neural networks and deep learning. The authors offer the complete text as an online reader for personal use. The book stays under copyright, so the button below opens the official reader instead of a file.
The book is mathematical by design. It builds each method from geometric, algebraic and probabilistic ideas, and it assumes linear algebra, calculus and probability. Part I covers data analysis foundations, kernels and PCA. Part II covers itemset, sequence and graph pattern mining. Part III covers clustering. Part IV covers classification, from Bayes and decision trees to SVMs and ensembles, and Part V covers regression, neural networks and deep learning. There is no program code, so plan to implement the algorithms yourself in Python or R.
Book Overview
| Course | Data Mining / Machine Learning |
| Degree Programs | BS Data Science, BSCS |
| Level | Senior undergraduate / graduate (mathematical) |
| Edition | Second Edition, Cambridge University Press, March 2020 (the first edition, from 2014, was titled Data Mining and Analysis) |
| Authors | Mohammed J. Zaki and Wagner Meira Jr. |
| Publisher | Cambridge University Press |
| Copyright | © Mohammed J. Zaki and Wagner Meira Jr. 2020; all rights reserved, free to read online for personal use |
| Total Chapters | 27 chapters in five parts (Part I: 1–7, Part II: 8–12, Part III: 13–17, Part IV: 18–22, Part V: 23–27) |
| Exercises | End-of-chapter exercises in every chapter, more than 180 numbered questions in all; no solutions in the book (an instructor solutions manual is available by request) |
| Prerequisites | Linear algebra, basic multivariable calculus, probability and statistics; no program code in the book |
| Language | English |
| Format | Free online reader with the full text (about 770 printed pages); no PDF download; print and e-book editions from Cambridge University Press |
Chapter List
The book is divided into five parts that the authors declare themselves, and this page follows them: Part I (Chapters 1 to 7) on data analysis foundations, Part II (Chapters 8 to 12) on frequent pattern mining, Part III (Chapters 13 to 17) on clustering, Part IV (Chapters 18 to 22) on classification and Part V (Chapters 23 to 27) on regression. All 27 chapters have full text, so there is one block per chapter. Chapter 1 is called Data Matrix in the book’s own contents, although the website’s reader menu labels it Data Mining and Analysis.
Chapter 1: Data Matrix
Part I: Data Analysis Foundations · Difficulty: Easy · Key topics: data matrix, attributes, Euclidean distance, angle, mean vector, total variance, orthogonal projection, random variable, random sample
The chapter models a dataset as an n by d data matrix whose rows are entities and whose columns are attributes, using the 150 by 5 Iris flower data as the running example. It separates numeric from categorical attributes and then looks at the same matrix in two ways. The algebraic and geometric view treats each row as a point in d-dimensional space and covers distance, angle, the mean and total variance, orthogonal projection and linear independence. The probabilistic view treats each attribute as a random variable and introduces bivariate and multivariate random variables, random samples and statistics.
Key Points:
- In an n by d data matrix, n is the size of the data and d is its dimensionality.
- Analysing one attribute is univariate, two is bivariate and more than two is multivariate analysis.
- Distance between points and the angle between vectors (through the dot product) are the basic tools for measuring similarity.
- The mean vector is the centre of the data and the total variance is the average squared distance of the points from it.
- Projecting a point orthogonally onto a direction gives the part of the point that lies along that direction.
- A statistic is any function of a random sample, and the sample mean is a statistic that estimates the population mean.
Memory Tip: Rows are things, columns are properties. Size n asks how many things you have, dimensionality d asks how many properties describe each one.
Common Mistake: Mixing up n and d, or treating a column as a data point. Every later formula in the book depends on which index runs over rows and which over attributes.
Important Questions:
- What is the difference between the size and the dimensionality of a dataset? Size is the number of rows n (entities), dimensionality is the number of columns d (attributes).
- Why does the book look at data both geometrically and probabilistically? The geometric view gives intuition through points, distances and projections, while the probabilistic view lets us estimate distributions and parameters from a random sample.
Chapter 2: Numeric Attributes
Part I: Data Analysis Foundations · Difficulty: Medium · Key topics: empirical CDF, mean, median, variance, covariance, correlation, covariance matrix, normalization, normal distribution, Mahalanobis distance
This chapter gives the statistical toolkit for exploring numeric attributes. For one attribute it builds the empirical cumulative distribution and mass functions and the measures of centre (mean, median, mode) and spread (range, quartiles, variance). For two attributes it turns to covariance and correlation, and for many attributes to the covariance matrix and the generalized variance. It then covers range normalization and standard score normalization, and finishes with the univariate and multivariate normal distributions, including how the eigenvectors of the covariance matrix give the axes of the contour ellipses.
Key Points:
- The empirical CDF at x is the fraction of sample points that are less than or equal to x.
- The median and quartiles are robust to outliers, while the mean and variance are not.
- Covariance measures how two attributes vary together, and correlation rescales it to lie between -1 and 1.
- The covariance matrix is symmetric, and its entries are the pairwise covariances of all attributes.
- Standard score normalization subtracts the mean and divides by the standard deviation, while range normalization rescales values into a fixed interval.
- The multivariate normal distribution is fully described by its mean vector and covariance matrix.
Memory Tip: Covariance has units, correlation does not. If you want to compare how strongly two attributes move together, always look at correlation.
Common Mistake: Concluding that two attributes are unrelated because their correlation is near zero. Correlation only measures linear association.
Important Questions:
- What is the difference between covariance and correlation? Covariance is the average product of deviations from the means and depends on the scale, while correlation divides by both standard deviations so it is unit-free and bounded by -1 and 1.
- When should attributes be normalized before analysis? When attributes have very different scales, because distance-based and variance-based methods would otherwise be dominated by the attribute with the largest values.
Chapter 3: Categorical Attributes
Part I: Data Analysis Foundations · Difficulty: Medium · Key topics: Bernoulli variable, multivariate Bernoulli, multinomial distribution, contingency table, chi-squared test, Hamming distance, cosine, discretization
Categorical values are only symbols, so this chapter works with their frequencies. A two-valued attribute is modelled as a Bernoulli variable, and an attribute with m values as a multivariate Bernoulli variable, with the sample mean and covariance computed from counts. For two attributes it builds a contingency table and uses the chi-squared test to decide whether they are dependent, then extends the idea to multiway tables. It also shows how to measure distance and angle between categorical points after one-hot style encoding, and how to discretize a numeric attribute into equal-width or equal-frequency bins.
Key Points:
- A Bernoulli variable with parameter p has mean p and variance p(1 – p).
- The multinomial distribution models how often each of the m symbols occurs in n independent draws.
- A contingency table counts how often each pair of values occurs, and its margins give the univariate counts.
- The chi-squared statistic compares observed counts with the counts expected if the two attributes were independent.
- Equal-width binning gives bins of the same length, while equal-frequency binning gives bins with about the same number of points.
Memory Tip: Chi-squared is observed minus expected, squared, divided by expected, summed over every cell. A big value means the table is far from independence.
Common Mistake: Treating category codes such as 1, 2, 3 as numbers and computing a mean. Encode the categories first, or analyse their counts.
Important Questions:
- How do you test whether two categorical attributes are independent? Build the contingency table, compute the expected counts from the margins, and compare the chi-squared statistic with its critical value or p-value.
- What is the difference between equal-width and equal-frequency discretization? Equal-width splits the range into intervals of equal length, which is sensitive to outliers, while equal-frequency puts roughly the same number of points in each bin.
Chapter 4: Graph Data
Part I: Data Analysis Foundations · Difficulty: Medium · Key topics: graph, degree, path, clustering coefficient, centrality, PageRank, prestige, Erdos-Renyi model, small world, scale-free
The chapter moves from independent points to linked data such as the Web and social networks. It first defines graphs, adjacency, degree, paths and connectivity, and then the topological attributes diameter and clustering coefficient. A long section on centrality ranks vertices by degree, eccentricity, closeness and betweenness for undirected graphs, and by prestige, PageRank and hubs and authorities for directed Web graphs, with the power iteration method for the dominant eigenvector. The last section compares real networks with three generative models: Erdos-Renyi random graphs, the Watts-Strogatz small-world model and the Barabasi-Albert scale-free model.
Key Points:
- The degree of a vertex is the number of edges it touches, and the degree distribution describes the whole graph.
- The clustering coefficient of a vertex is the fraction of pairs of its neighbours that are themselves connected.
- Eccentricity, closeness and betweenness measure how central a vertex is by distances and shortest paths.
- PageRank and prestige are defined as the dominant eigenvector of a transition-style matrix and can be found by power iteration.
- Many real graphs have a small average path length, high clustering and a power-law degree distribution (scale-free).
- Preferential attachment, where new nodes link to already popular nodes, produces the scale-free property in the Barabasi-Albert model.
Memory Tip: Small world means short paths, clustering means friends of friends are friends, scale-free means a few huge hubs. A good graph model must reproduce all three.
Common Mistake: Assuming the most connected vertex is always the most central. Degree centrality ignores where a vertex sits, which betweenness and PageRank capture.
Important Questions:
- What is the difference between degree centrality and betweenness centrality? Degree counts a vertex’s direct neighbours, while betweenness counts the fraction of shortest paths between other pairs that pass through the vertex.
- Why does the Erdos-Renyi model fail to match real networks? It gives a narrow degree distribution and little clustering, whereas real networks have hubs (power-law degrees) and strong local clustering.
Chapter 5: Kernel Methods
Part I: Data Analysis Foundations · Difficulty: Hard · Key topics: kernel function, kernel matrix, positive semidefinite, Mercer map, polynomial kernel, Gaussian kernel, feature space, spectrum kernel, diffusion kernel
Kernels let us run linear methods on nonlinear or complex data. The chapter starts from the idea of a mapping into a feature space, then defines the kernel matrix of pairwise similarities and shows that a symmetric positive semidefinite kernel always corresponds to a dot product in some feature space, built through the reproducing kernel map or the Mercer map. It describes the polynomial and Gaussian vector kernels, and shows that norms, distances, means, variance and centering can all be computed from the kernel matrix alone. It closes with kernels for strings (the spectrum kernel) and for graph nodes (diffusion kernels).
Key Points:
- A kernel K(x, y) equals the dot product of the mapped points in feature space, so the mapping never has to be computed.
- A valid kernel matrix is symmetric and positive semidefinite, meaning all its eigenvalues are non-negative.
- The polynomial kernel captures interactions up to a chosen degree, and the Gaussian kernel corresponds to an infinite-dimensional feature space.
- Distances, norms, the mean and the variance in feature space can be written entirely in terms of kernel values.
- The spectrum kernel compares two strings by the counts of the substrings of a fixed length that they share.
Memory Tip: The kernel trick in one line: if an algorithm only needs dot products, replace each dot product with K(x, y) and you get a nonlinear algorithm for free.
Common Mistake: Using a similarity function that is not positive semidefinite as a kernel. The mathematics behind later chapters (kernel PCA, SVM) then breaks down.
Important Questions:
- What is the kernel trick? It computes dot products in a high-dimensional feature space directly from a kernel function, so nonlinear patterns can be found with linear methods without building the feature vectors.
- What makes a function a valid kernel? It must be symmetric and positive semidefinite, which guarantees it is a dot product in some feature space (Mercer’s condition).
Chapter 6: High-dimensional Data
Part I: Data Analysis Foundations · Difficulty: Medium · Key topics: hypercube, hypersphere volume, inscribed sphere, thin shell, diagonals, multivariate normal density, sparsity in high dimensions
The chapter explains why geometry in hundreds of dimensions disagrees with our two- and three-dimensional intuition. It computes the volumes of hypercubes and hyperspheres and shows that a sphere inscribed in a cube holds a vanishing fraction of the cube as the dimension grows, so most points lie near corners and the centre is almost empty. A thin shell just inside the surface of a hypersphere holds almost all of its volume, the diagonals of a hypercube become nearly orthogonal to every axis, and the multivariate normal puts little density near its mean. An appendix derives the hypersphere volume by integration.
Key Points:
- The volume of a hypercube with edge length l in d dimensions is l to the power d.
- The ratio of an inscribed hypersphere’s volume to the cube’s volume tends to zero as d grows.
- Almost all the volume of a hypersphere lies in a thin shell just below its surface.
- Hypercube diagonals become nearly perpendicular to every coordinate axis in high dimensions.
- For a multivariate normal in high dimensions, very few points lie close to the mean, so the peak holds little probability.
Memory Tip: Think of an orange in many dimensions: nearly all of it is peel. The same happens to data in high dimensions, which is why points are scattered along the boundary.
Common Mistake: Assuming more attributes always means more information. In very high dimensions distances become less informative and data becomes sparse.
Important Questions:
- What is the curse of dimensionality in geometric terms? As dimension grows, the centre of the space empties out, volume concentrates near the surface and corners, and points become almost equally far apart.
- What happens to the volume of an inscribed hypersphere compared with its hypercube? The fraction goes to zero, so the sphere fills almost none of the cube in high dimensions.
Chapter 7: Dimensionality Reduction
Part I: Data Analysis Foundations · Difficulty: Hard · Key topics: principal component analysis, covariance matrix, eigenvectors, fraction of total variance, kernel PCA, singular value decomposition
Starting from the problems of high dimensions, this chapter derives principal component analysis (PCA) as the search for the r-dimensional subspace that captures the most variance. It first finds the best one-dimensional line, then the best r-dimensional approximation, and shows that the principal components are the leading eigenvectors of the covariance matrix and that the chosen eigenvalues give the variance explained. The geometry of PCA is explained as a change of basis. Kernel PCA does the same in feature space using the centered kernel matrix, and the chapter closes with the singular value decomposition and its link to PCA.
Key Points:
- The first principal component is the direction of maximum projected variance, and it is the eigenvector of the covariance matrix with the largest eigenvalue.
- The data must be centered (mean subtracted) before computing the covariance matrix.
- The fraction of total variance captured by r components is the sum of the top r eigenvalues divided by the sum of all eigenvalues.
- PCA minimizes the mean squared error between the points and their projections.
- Kernel PCA finds nonlinear directions by eigen-decomposing the centered kernel matrix.
- For a centered data matrix, SVD gives the principal directions in its right singular vectors, and the squared singular values relate to the eigenvalues of the covariance matrix.
Practice Tip: Load the Iris data in Python or R, center it, and compute the eigenvectors of its covariance matrix by hand. Then check that the first two components keep most of the total variance.
Common Mistake: Forgetting to center the data, or comparing components when attributes have very different scales. PCA is driven by variance, so scale matters.
Important Questions:
- How are the principal components related to the covariance matrix? They are its eigenvectors, ordered by eigenvalue, and each eigenvalue is the variance of the data along that component.
- How is SVD related to PCA? For a centered data matrix, the right singular vectors are the principal directions and the squared singular values are proportional to the covariance eigenvalues, so SVD gives PCA without forming the covariance matrix.
Chapter 8: Itemset Mining
Part II: Frequent Pattern Mining · Difficulty: Medium · Key topics: itemset, tidset, support, minsup, Apriori, Eclat, diffset, FP-tree, FPGrowth, association rule, confidence
The chapter opens with the market-basket style problem of finding items that co-occur, and defines itemsets, transactions, support and association rules. It first shows a brute-force enumeration of all itemsets and why it explodes, then three better strategies. Apriori works level by level using the fact that every subset of a frequent itemset is frequent. Eclat uses a vertical layout and intersects tidsets, with diffsets to save space. FPGrowth compresses the database into a prefix tree and mines it by projection. The last section generates association rules from frequent itemsets using confidence.
Key Points:
- The support of an itemset is the number of transactions that contain it, and it is frequent if support is at least minsup.
- Apriori prunes candidates using the property that every subset of a frequent itemset must also be frequent.
- Eclat stores for each item the set of transaction ids (its tidset) and finds the support of a longer itemset by intersecting tidsets.
- Diffsets store only the difference between tidsets, which shrinks memory use on dense data.
- FPGrowth builds an FP-tree (a prefix tree of transactions) and mines it recursively without generating candidates.
- The confidence of a rule X to Y is support(X and Y) divided by support(X).
Practice Tip: Implement Apriori on a small transaction table in Python. Print the candidates and frequent itemsets at every level and watch how pruning removes candidates.
Common Mistake: Mixing up support and confidence. Support is about an itemset, confidence is about a rule, and a rule can have high confidence with tiny support.
Important Questions:
- How does Apriori reduce the number of candidate itemsets? It builds candidates of size k+1 only from frequent itemsets of size k, since any itemset with an infrequent subset cannot itself be frequent.
- How do Eclat and FPGrowth differ from Apriori? Eclat counts support by intersecting vertical tidsets, and FPGrowth compresses the data into an FP-tree and avoids candidate generation, while Apriori scans the database level by level.
Chapter 9: Summarizing Itemsets
Part II: Frequent Pattern Mining · Difficulty: Medium · Key topics: maximal itemset, closed itemset, minimal generator, GenMax, Charm, nonderivable itemset, condensed representation
A low support threshold can produce millions of frequent itemsets, so this chapter looks for smaller summaries that still capture the essentials. It defines maximal frequent itemsets (no frequent superset) and closed frequent itemsets (no superset with the same support), relates closed itemsets to minimal generators, and gives the GenMax algorithm for maximal sets and the Charm algorithm for closed sets, both built on tidset search. The last section covers nonderivable itemsets, whose support cannot be deduced from the supports of their subsets using bounds from inclusion and exclusion.
Key Points:
- A frequent itemset is maximal if none of its supersets is frequent.
- A frequent itemset is closed if none of its supersets has the same support.
- Maximal itemsets are the smallest summary, but they lose the exact supports of their subsets, while closed itemsets keep all support information.
- Every maximal frequent itemset is also closed, so maximal sets are a subset of closed sets.
- An itemset is nonderivable when its support cannot be computed exactly from the supports of its subsets.
Memory Tip: Maximal means nothing bigger is frequent. Closed means nothing bigger has the same support. Maximal is a stronger condition, so there are fewer maximal sets than closed sets.
Common Mistake: Thinking maximal and closed sets are interchangeable. You can rebuild every support from the closed itemsets, but not from the maximal ones.
Important Questions:
- What is the difference between a closed and a maximal frequent itemset? A closed itemset has no superset with equal support, while a maximal itemset has no frequent superset at all.
- Why are condensed representations useful? They reduce storage and computation and make the results easier to read, while closed itemsets still allow the support of any frequent itemset to be recovered.
Chapter 10: Sequence Mining
Part II: Frequent Pattern Mining · Difficulty: Hard · Key topics: sequence, subsequence, substring, GSP, SPADE, PrefixSpan, suffix tree, Ukkonen algorithm
When order matters, as in DNA, click streams or text, itemset methods are not enough. This chapter defines sequences over an alphabet and frequent subsequences that allow gaps, and searches the prefix tree of all possible sequences. GSP works level by level, SPADE uses a vertical layout of sequence ids and positions, and PrefixSpan projects the database on each prefix. The second half covers substrings, which allow no gaps, and shows how suffix trees, built with Ukkonen’s linear-time method, find frequent substrings far faster than generic methods.
Key Points:
- A subsequence may skip symbols, while a substring must be contiguous.
- Because order matters, the search space has permutations of symbols, not just combinations as in itemset mining.
- GSP is level-wise, SPADE is vertical (it joins id and position lists) and PrefixSpan is projection-based.
- A suffix tree stores all suffixes of a string, with a terminal symbol
$marking the end of the string. - Ukkonen’s algorithm builds a suffix tree in time linear in the length of the string.
Practice Tip: Write the suffix tree of a short word such as BANANA by hand, then use it to count how many times each substring appears.
Common Mistake: Using a subsequence algorithm when the problem needs contiguous substrings, or the other way round. The two problems have very different costs.
Important Questions:
- What is the difference between a subsequence and a substring? A subsequence keeps the order of symbols but may leave gaps, while a substring is a contiguous run of symbols.
- Why is a suffix tree useful for substring mining? It indexes every substring of the data in one structure, so the frequency of any substring can be read off the tree, and Ukkonen’s method builds it in linear time.
Chapter 11: Graph Pattern Mining
Part II: Frequent Pattern Mining · Difficulty: Hard · Key topics: subgraph isomorphism, support, rightmost path extension, DFS code, canonical code, gSpan
Frequent subgraph mining searches a database of graphs for patterns that occur in many of them. The chapter defines graph and subgraph isomorphism and the support of a subgraph, then shows how to generate candidates without repeats by extending a depth-first-search code along the rightmost path. Duplicate candidates are removed by choosing one canonical (minimum) DFS code. The gSpan algorithm combines extension, support counting and canonicality checking so that expensive isomorphism tests are avoided as far as possible.
Key Points:
- Support of a subgraph is the number of graphs in the database that contain it.
- Testing subgraph isomorphism is computationally hard, so the algorithm tries to do as little of it as possible.
- Rightmost path extension adds new edges only along the rightmost path of the DFS tree, so each pattern is built in a systematic way.
- Isomorphic candidates are detected by comparing DFS codes, and only the canonical (smallest) code is extended further.
- gSpan computes support while extending, using the embeddings of the parent pattern.
Memory Tip: Same graph, many DFS codes. Canonical means pick one agreed code (the minimum) so every graph has exactly one name.
Common Mistake: Treating graph mining as a simple extension of itemset mining. Two different-looking graphs can be the same graph, which is why canonical codes are needed.
Important Questions:
- Why does graph mining need a canonical code? The same pattern can be generated through different extension orders, and a canonical DFS code lets the algorithm keep one copy and discard isomorphic duplicates.
- What is rightmost path extension? It is the rule that new edges may be added only from the vertices on the rightmost path of the DFS tree, which keeps candidate generation systematic and limits duplicates.
Chapter 12: Pattern and Rule Assessment
Part II: Frequent Pattern Mining · Difficulty: Hard · Key topics: lift, leverage, conviction, odds ratio, productive rule, Fisher exact test, swap randomization, permutation test, bootstrap confidence interval
Mining returns far more rules than anyone can read, so this chapter asks which of them are worth keeping. It reviews rule measures beyond support and confidence (such as lift, leverage, conviction and the odds ratio) and measures for patterns and for comparing many rules, including the idea of a productive rule that improves on its generalizations. The second half brings in statistics: the Fisher exact test for productivity, permutation tests through swap randomization of the dataset to get p-values, and bootstrap resampling to build confidence intervals for a measure.
Key Points:
- Lift compares the confidence of a rule with the support of its consequent, and a value near 1 means the two sides are roughly independent.
- Leverage is the difference between the observed support of a rule and the support expected under independence.
- A rule is productive if its confidence is higher than that of each of its more general rules.
- Swap randomization shuffles the dataset while keeping the row and column totals, giving a null distribution for a pattern’s support.
- Bootstrap resampling draws many samples with replacement to give a confidence interval for a measure such as support.
Memory Tip: Lift is the surprise factor. Lift 1 means no surprise, lift well above 1 means the items appear together more often than chance.
Common Mistake: Trusting high-confidence rules without checking significance. A rule can have high confidence only because its consequent is already very common.
Important Questions:
- What does lift tell you about an association rule? It shows how many times more often the antecedent and consequent occur together than they would if independent, so lift above 1 means positive association.
- How is a p-value obtained for a mined pattern? Generate many randomized datasets (for example by swap randomization), compute the pattern’s support in each, and see how extreme the observed support is among them.
Chapter 13: Representative-based Clustering
Part III: Clustering · Difficulty: Hard · Key topics: K-means, sum of squared errors, kernel K-means, Gaussian mixture, expectation-maximization, soft assignment, maximum likelihood
The chapter groups points around one representative per cluster. K-means assigns each point to the nearest mean and updates the means, greedily lowering the sum of squared errors, and it is shown to run in time proportional to the number of iterations, points, clusters and dimensions. Kernel K-means repeats this in feature space so clusters can have nonlinear boundaries. The long final section develops expectation-maximization for a mixture of normal distributions, first in one dimension and then in d dimensions, derives the maximum likelihood estimates and explains EM as alternating expectation and maximization steps with soft assignments.
Key Points:
- K-means minimizes the sum of squared distances between points and their cluster means.
- The result depends on the starting means and can be a local rather than a global optimum, so it is usual to run it several times.
- K-means makes hard assignments, where each point belongs to exactly one cluster.
- Kernel K-means uses only the kernel matrix, so it can find clusters that are not linearly separable.
- EM models the data as a mixture of normals and gives each point a probability of belonging to each cluster (soft assignment).
- The E-step computes the posterior probability of each cluster for every point, and the M-step re-estimates the means, covariances and priors.
Practice Tip: Run K-means on Iris with k = 3 using different random starts. Compare the final SSE values and see how often you reach the same clusters.
Common Mistake: Believing K-means finds the best possible clustering. It only converges to a local minimum, and it needs k to be chosen in advance.
Important Questions:
- What is the difference between K-means and EM clustering? K-means gives hard assignments to spherical clusters by minimizing squared error, while EM fits a mixture of Gaussians with full covariances and gives soft probabilities.
- What do the E-step and M-step do? The E-step computes each cluster’s posterior probability for each point under the current parameters, and the M-step updates the parameters to maximize the expected log-likelihood.
Chapter 14: Hierarchical Clustering
Part III: Clustering · Difficulty: Medium · Key topics: dendrogram, agglomerative clustering, single link, complete link, group average, Ward, Lance-Williams formula
Hierarchical clustering builds a tree of nested clusters, called a dendrogram, instead of a single partition. The chapter focuses on the agglomerative (bottom-up) method, which starts with each point as its own cluster and repeatedly merges the closest pair until one cluster remains. The distance between clusters can be single link, complete link, group average, mean distance or Ward’s minimum variance, and the chapter shows how the Lance-Williams formula updates the distance matrix after each merge. It ends with the running time: keeping the pairwise distances in a heap gives O(n squared log n) overall.
Key Points:
- The leaves of the dendrogram are single points and the root is the whole dataset; cutting the tree at a level gives a clustering.
- Single link uses the minimum distance between clusters and complete link uses the maximum.
- Group average uses the average pairwise distance, and Ward’s method merges the pair that increases the sum of squared errors the least.
- The Lance-Williams formula updates the distance from a merged cluster to every other cluster without recomputing from the points.
- Agglomerative clustering needs the full distance matrix, so it is costly for very large datasets.
Memory Tip: Single link = nearest neighbours decide, so it can chain clusters together. Complete link = farthest members decide, so it prefers compact clusters.
Common Mistake: Expecting one dendrogram to be the answer for every linkage. Different linkages can give very different trees on the same data.
Important Questions:
- What is the difference between single link and complete link? Single link measures cluster distance by the closest pair of points, and complete link by the farthest pair, so single link can chain and complete link yields tighter clusters.
- What is the time complexity of agglomerative clustering? With all pairwise distances kept in a heap it takes O(n squared log n) time in total, and the distance matrix itself needs O(n squared) space.
Chapter 15: Density-based Clustering
Part III: Clustering · Difficulty: Hard · Key topics: DBSCAN, core point, border point, noise point, eps neighbourhood, MinPts, kernel density estimation, DENCLUE, density attractor
K-means and EM struggle when clusters are not convex, which is the problem this chapter attacks. DBSCAN defines a neighbourhood radius and a minimum number of points, labels each point as core, border or noise, and grows clusters by connecting core points that are density-reachable. The middle section lays the foundation with kernel density estimation in one and many dimensions, plus nearest neighbour density estimation. DENCLUE then finds the peaks of the estimated density by gradient ascent and assigns points to the density attractor they climb to.
Key Points:
- DBSCAN has two parameters: the radius epsilon and the minimum number of points MinPts.
- A core point has at least MinPts points in its epsilon-neighbourhood, a border point is within a core point’s neighbourhood but is not core, and everything else is noise.
- DBSCAN needs no number of clusters in advance and can find clusters of arbitrary shape.
- Kernel density estimation places a kernel (for example Gaussian) on each point and sums them to get a smooth density.
- DENCLUE moves each point uphill on the density surface to a density attractor, and points with the same attractor form a cluster.
Memory Tip: Core = a crowded neighbourhood, border = on the edge of a crowd, noise = alone. Clusters are crowds linked through their core points.
Common Mistake: Using one epsilon for data with clusters of very different densities. DBSCAN has a single global density threshold.
Important Questions:
- What are core, border and noise points in DBSCAN? Core points have at least MinPts points within epsilon, border points lie in a core point’s neighbourhood but have fewer, and noise points are neither.
- How does DENCLUE relate density estimation to clustering? It estimates the density with a kernel, climbs to local maxima (density attractors) by gradient ascent, and groups points by the attractor they reach.
Chapter 16: Spectral and Graph Clustering
Part III: Clustering · Difficulty: Hard · Key topics: similarity graph, adjacency matrix, Laplacian, ratio cut, normalized cut, spectral clustering, modularity, Markov clustering, expansion, inflation
This chapter clusters the nodes of a weighted graph, whether it is given or built from point similarities. It reviews the adjacency, degree and Laplacian matrices, then casts clustering as finding a k-way cut that optimizes an objective, with ratio cut and normalized cut as the main minimization objectives. The spectral clustering algorithm solves a relaxed version using the smallest eigenvectors of the Laplacian and then clusters the rows with K-means. The chapter also treats maximization objectives (average weight and modularity) and the Markov clustering algorithm, which alternates expansion and inflation of a random-walk matrix.
Key Points:
- The graph Laplacian is the degree matrix minus the adjacency matrix, and it is symmetric and positive semidefinite.
- Ratio cut and normalized cut divide the weight of the edges cut by cluster size and by cluster volume, which avoids tiny clusters.
- Spectral clustering takes the leading eigenvectors of a graph matrix as new coordinates and then runs K-means on them.
- Modularity compares the edge weight inside clusters with what a random graph with the same degrees would give.
- Markov clustering repeats expansion (powers of the transition matrix) and inflation (raising entries to a power) until clusters emerge.
Memory Tip: Spectral clustering in three steps: build the graph, take eigenvectors of its Laplacian, run K-means on the rows of the eigenvector matrix.
Common Mistake: Minimizing the plain cut weight, which happily cuts off a single node. Ratio cut and normalized cut exist to prevent exactly that.
Important Questions:
- Why is normalized cut preferred to a simple minimum cut? A plain minimum cut tends to isolate single vertices, while normalized cut penalizes unbalanced clusters by dividing by their volume.
- What do expansion and inflation do in Markov clustering? Expansion raises the transition matrix to a power, spreading flow along longer walks, and inflation strengthens strong flows and weakens weak ones, which separates the clusters.
Chapter 17: Clustering Validation
Part III: Clustering · Difficulty: Hard · Key topics: purity, F-measure, conditional entropy, normalized mutual information, Rand index, Jaccard, silhouette coefficient, Dunn index, gap statistic, cluster stability, Hopkins statistic
With so many algorithms, we need objective ways to judge a clustering, and this chapter groups them into three tasks: evaluation, stability and tendency. External measures compare a clustering with known labels using matching measures (purity, maximum matching, F-measure), entropy measures (conditional entropy, normalized mutual information) and pairwise measures (Jaccard, Rand, Fowlkes-Mallows), plus correlation measures. Internal measures such as the silhouette coefficient and the Dunn index need no labels. Relative measures help choose k, including the gap statistic and a stability algorithm. The last part tests clustering tendency with the Hopkins statistic.
Key Points:
- External measures need ground-truth labels, internal measures use only the data and the clustering.
- Purity measures how much of each cluster belongs to a single true class.
- Mutual information based measures compare two clusterings by how much knowing one tells you about the other.
- The silhouette coefficient of a point compares its average distance to its own cluster with its distance to the nearest other cluster.
- The gap statistic and cluster stability are relative measures for choosing the number of clusters k.
- The Hopkins statistic checks whether the data has a meaningful cluster structure at all.
Memory Tip: Three questions for any clustering: is it good (evaluation), is it repeatable on resampled data (stability), and is there anything to cluster in the first place (tendency).
Common Mistake: Picking k by the lowest SSE alone. SSE always falls as k grows, so you need a relative measure such as silhouette, gap statistic or stability.
Important Questions:
- What is the difference between external and internal clustering measures? External measures compare the clustering with known class labels, while internal measures judge compactness and separation using only the data itself.
- How can you choose the number of clusters k? Run the algorithm for several values of k and compare relative measures such as the silhouette coefficient, the gap statistic or cluster stability.
Chapter 18: Probabilistic Classification
Part IV: Classification · Difficulty: Medium · Key topics: Bayes classifier, prior, likelihood, posterior, multivariate normal, naive Bayes, K nearest neighbours
Part IV begins with classifiers that predict the class with the highest posterior probability. The full Bayes classifier uses Bayes theorem and estimates the class priors from the training counts and the class-conditional density from the data, usually by fitting a multivariate normal to each class. Because that needs about d squared parameters per class, the naive Bayes classifier assumes the attributes are independent given the class, which cuts the estimation to about d parameters and works surprisingly well. The last section gives the nonparametric K nearest neighbours classifier, which estimates densities directly from nearby points.
Key Points:
- The Bayes classifier predicts the class that maximizes the posterior, which is proportional to the likelihood times the prior.
- The prior of a class is estimated by the fraction of training points in that class.
- Estimating a full covariance matrix for every class takes about d squared parameters, which is unreliable in high dimensions.
- Naive Bayes assumes conditional independence of attributes, so the likelihood becomes a product of one-dimensional likelihoods.
- K nearest neighbours uses the labels of the K closest training points and makes no distributional assumption.
Practice Tip: Classify a new point with both full Bayes and naive Bayes on a small table, and compare the posteriors to see where the independence assumption changes the answer.
Common Mistake: Believing naive Bayes needs truly independent attributes to work. It often classifies well even when the assumption is wrong, though its probabilities are not well calibrated.
Important Questions:
- What does the naive in naive Bayes mean? It assumes the attributes are independent given the class, so the joint likelihood factors into a product of per-attribute likelihoods.
- How is the class decided in the Bayes classifier? Compute the posterior probability of every class for the point and choose the class with the largest value.
Chapter 19: Decision Tree Classifier
Part IV: Classification · Difficulty: Medium · Key topics: decision tree, split point, entropy, information gain, Gini index, CART measure, leaf purity, axis-parallel hyperplane
A decision tree classifier recursively splits the data space with axis-parallel boundaries until the regions are almost pure, which makes the model easy to read. The chapter defines the tree and then the construction algorithm, which takes a leaf-size threshold and a purity threshold. It explains how to score a split with entropy and information gain, the Gini index or the CART measure, and gives the procedures for evaluating split points on numeric attributes (trying midpoints between sorted values) and on categorical attributes (trying subsets of values). It finishes with the computational complexity of building the tree.
Key Points:
- Internal nodes hold a test on one attribute, and leaves hold the predicted class.
- Entropy measures how mixed the classes are at a node, and information gain is the drop in entropy after a split.
- The Gini index and the CART measure are alternative scores for judging a split.
- For a numeric attribute, candidate split points lie between consecutive sorted values.
- The algorithm stops splitting when a node is small enough or pure enough, according to its two thresholds.
Practice Tip: Compute the entropy and the information gain for each attribute of a ten-row table on paper, and then see which attribute a tree would split on first.
Common Mistake: Growing a tree until every leaf is perfectly pure. Deep trees memorize the training data, and the chapter itself points to other references for pruning rather than covering it.
Important Questions:
- How does a decision tree choose the best split? It evaluates every candidate split with a measure such as information gain or the Gini index and picks the one that makes the child nodes purest.
- What is information gain? It is the entropy of the parent node minus the weighted average entropy of its children after the split.
Chapter 20: Linear Discriminant Analysis
Part IV: Classification · Difficulty: Hard · Key topics: Fisher discriminant, between-class scatter, within-class scatter, projection direction, eigenvalue problem, kernel discriminant analysis
Linear discriminant analysis looks for a direction such that, after projecting the labelled points onto it, the classes are as well separated as possible. The chapter contrasts it with PCA: PCA maximizes total variance and ignores labels, while LDA uses the labels. It defines the between-class and within-class scatter matrices, sets up the objective of large separation of projected means relative to the scatter inside classes, and solves it as a generalized eigenvalue problem. The second section extends the method to feature space with kernels, giving kernel discriminant analysis for nonlinear boundaries.
Key Points:
- LDA is supervised, since it uses class labels, while PCA is unsupervised.
- The objective is to maximize the separation of the projected class means relative to the within-class scatter.
- The best direction comes from an eigenvalue problem involving the within-class and between-class scatter matrices.
- The chapter derives LDA for two classes, where a single discriminant direction is enough.
- Kernel discriminant analysis works only through the kernel matrix, so it can separate classes that are not linearly separable in the input space.
Memory Tip: PCA asks where the data varies most. LDA asks where the classes differ most compared with how much each class varies inside itself.
Common Mistake: Using PCA to prepare data for classification and assuming the top component separates the classes. The direction of largest variance may be useless for the labels.
Important Questions:
- How does LDA differ from PCA? LDA uses class labels to find the direction that best separates classes, while PCA ignores labels and maximizes total variance.
- What are the between-class and within-class scatter? Between-class scatter measures how far the class means are from each other, and within-class scatter measures how spread out the points are around their own class mean.
Chapter 21: Support Vector Machines
Part IV: Classification · Difficulty: Hard · Key topics: hyperplane, margin, support vectors, Lagrangian, dual problem, soft margin, hinge loss, kernel SVM, stochastic gradient ascent
This chapter builds the SVM step by step. It defines hyperplanes, the margin and the support vectors, and then the linear separable case, where the maximum margin hyperplane is found by solving a constrained optimization problem through its Lagrangian and dual. The soft margin version allows violations through slack variables, with a hinge loss or a quadratic loss and a regularization constant. The kernel SVM replaces dot products with a kernel to get nonlinear boundaries, and the final section trains the dual with stochastic gradient ascent, which avoids a general quadratic programming solver.
Key Points:
- The margin is the distance from the separating hyperplane to the closest points, and the SVM chooses the hyperplane with the largest margin.
- Support vectors are the training points that lie on the margin, and only they determine the hyperplane.
- The dual problem depends on the data only through dot products, which is what makes kernels possible.
- The soft margin SVM adds slack variables and a constant C that trades margin width against training errors.
- Hinge loss and quadratic loss are the two penalties for margin violations that the chapter compares.
- In the dual, stochastic gradient ascent updates one Lagrange multiplier at a time.
Memory Tip: Only the points closest to the boundary matter. Delete every other point and the maximum margin hyperplane stays the same.
Common Mistake: Treating C as a fixed property of the data. A large C punishes errors heavily and can overfit, while a small C allows a wider margin with more violations, so C should be tuned.
Important Questions:
- What is a support vector? It is a training point that lies on the margin boundary (or inside it, in the soft margin case) and has a nonzero Lagrange multiplier, so it defines the decision boundary.
- Why is the dual formulation useful for SVMs? It expresses the problem in terms of dot products between points only, so any kernel can be plugged in to get a nonlinear classifier.
Chapter 22: Classification Assessment
Part IV: Classification · Difficulty: Hard · Key topics: confusion matrix, precision, recall, ROC curve, AUC, cross-validation, bootstrap, paired t-test, bias-variance, bagging, random forest, AdaBoost, stacking
The final chapter of Part IV asks how good a classifier really is. It defines accuracy and error rate, the confusion matrix for two classes (true and false positives and negatives), precision, recall and F-measure, and ROC analysis with the area under the curve. It then covers evaluation: K-fold cross-validation, bootstrap resampling, confidence intervals and a paired t-test for comparing two classifiers. The bias-variance decomposition of the error follows, and the chapter ends with ensemble methods that reduce variance or bias: bagging, random forests, boosting with AdaBoost, and stacking.
Key Points:
- Precision is the fraction of predicted positives that are correct, and recall is the fraction of actual positives that are found.
- An ROC curve plots the true positive rate against the false positive rate as the score threshold changes, and AUC summarizes it in one number.
- K-fold cross-validation uses each fold once as the test set, and the bootstrap draws samples with replacement.
- Expected error splits into bias, variance and irreducible noise, and complex models tend to have low bias but high variance.
- Bagging averages models trained on bootstrap samples, and a random forest also picks random attribute subsets at each split.
- AdaBoost trains classifiers in sequence and increases the weight of the points that earlier ones got wrong.
Memory Tip: Bagging cuts variance by averaging, boosting cuts bias by focusing on mistakes. Say it once and you will not mix them up in the exam.
Common Mistake: Judging a model by accuracy on the training set or on imbalanced data. Always use held-out data and report precision and recall when classes are uneven.
Important Questions:
- What is the difference between precision and recall? Precision measures how many of the points predicted positive are truly positive, and recall measures how many of the truly positive points were predicted positive.
- How does a random forest differ from bagging? Both train trees on bootstrap samples, but a random forest also restricts each split to a random subset of attributes, which decorrelates the trees and lowers variance further.
Chapter 23: Linear Regression
Part V: Regression · Difficulty: Hard · Key topics: least squares, bivariate regression, multiple regression, QR decomposition, ridge regression, kernel regression, lasso, subgradient
Part V, new in the second edition, starts with predicting a real-valued response. The chapter fits a line to one predictor and then generalizes to many predictors, with a strong geometric picture: the predicted vector is the projection of the response onto the space spanned by the predictors and the constant vector. It solves multiple regression exactly with QR decomposition and also with stochastic gradient descent. Ridge regression adds an L2 penalty, kernel regression gives nonlinear fits using the kernel trick, and the lasso uses an L1 penalty that drives some weights to zero, solved with subgradients.
Key Points:
- Least squares chooses the weights that minimize the sum of squared errors between predictions and responses.
- Geometrically, the fitted values are the orthogonal projection of the response vector onto the span of the predictors.
- QR decomposition of the augmented data matrix gives the solution without inverting the matrix of dot products.
- Ridge regression adds an L2 penalty on the weights, which shrinks them and stabilizes the fit when the data is noisy.
- The L1 penalty of the lasso can set some weights exactly to zero, so it performs a kind of feature selection.
- The absolute value is not differentiable at zero, which is why the lasso needs subgradients.
Practice Tip: Fit a bivariate regression on a small dataset by hand, then check that the residual vector is perpendicular to both the predictor and the constant column.
Common Mistake: Forgetting the bias term, or fitting ridge and lasso on attributes with different scales. The penalty then punishes some weights unfairly.
Important Questions:
- What is the geometric interpretation of linear regression? The predicted response vector is the orthogonal projection of the true response vector onto the subspace spanned by the attribute vectors and the constant vector, so the residual is orthogonal to that subspace.
- How do ridge regression and lasso differ? Ridge penalizes the squared L2 norm of the weights and shrinks them smoothly, while lasso penalizes the L1 norm and can make some weights exactly zero.
Chapter 24: Logistic Regression
Part V: Regression · Difficulty: Medium · Key topics: logistic function, odds, log-odds, maximum likelihood, gradient ascent, multiclass logistic regression, one-hot response
Logistic regression predicts a categorical response, so it is really a classifier built with regression ideas. For a binary response, it models the probability of class 1 as a logistic function of a linear combination of the predictors, which is the same as saying the log-odds are linear. The weights are learned by maximum likelihood, and because there is no closed form the chapter uses gradient ascent on the log-likelihood. The multiclass version represents the response as a one-hot vector, uses a softmax-style model over K classes and again derives the maximum likelihood gradient updates.
Key Points:
- The logistic function maps any real number into the interval from 0 to 1, so its output can be read as a probability.
- The log-odds of the positive class are a linear function of the predictors.
- Weights are found by maximizing the likelihood of the training labels, since least squares is not appropriate for a 0-1 response.
- The log-likelihood is optimized by gradient ascent, repeating small steps along the gradient.
- For K classes the response is a one-hot vector and the model gives a probability for each class.
Memory Tip: Logistic regression is a straight line in log-odds space. Bending that line through the logistic function turns scores into probabilities.
Common Mistake: Calling logistic regression a regression method for numeric prediction. It outputs class probabilities and is used for classification.
Important Questions:
- Why do we use maximum likelihood to train logistic regression? The response is a Bernoulli variable, so the likelihood of the labels is the natural objective, and maximizing it gives the weights that make the observed classes most probable.
- How does multiclass logistic regression extend the binary case? It models a one-hot response over K classes with one weight vector per class and normalizes the scores so the K probabilities add up to 1.
Chapter 25: Neural Networks
Part V: Regression · Difficulty: Hard · Key topics: artificial neuron, activation function, sigmoid, ReLU, softmax, error function, multilayer perceptron, backpropagation, net gradient, vanishing gradient
This chapter lays the foundation for deep learning. It starts with the artificial neuron as a weighted sum followed by an activation function, with the derivatives of the common activations. It shows that linear and logistic regression are special cases of a single neuron, and introduces the squared error and cross-entropy loss functions. Next it develops the multilayer perceptron with one hidden layer, working through the feed-forward phase and the backpropagation phase based on the net gradient of each layer, then generalizes to deep MLPs with many hidden layers, and warns about the vanishing and exploding gradient problem.
Key Points:
- A neuron computes a weighted sum of its inputs plus a bias and passes it through an activation function.
- Common activations include identity, sigmoid, tanh, ReLU and softmax, and each needs a derivative for training.
- Squared error is the usual loss for regression, and cross-entropy is the usual loss for classification.
- Feed-forward computes the outputs layer by layer, and backpropagation passes the net gradient from the output back to the input layers.
- Training uses stochastic gradient descent, updating weights using the gradient of the error.
- In very deep MLPs the gradient can shrink (vanishing) or grow (exploding) exponentially as it moves back through layers.
Practice Tip: Write a one-hidden-layer MLP using only NumPy and train it on a small dataset. Print the loss every epoch and the net gradients of each layer to see backpropagation at work.
Common Mistake: Treating backpropagation as a separate learning algorithm. It is just the chain rule used to compute the gradient efficiently, and gradient descent does the learning.
Important Questions:
- What is backpropagation? It is the method of computing the gradient of the error with respect to every weight by propagating the net gradient backward from the output layer to the hidden and input layers using the chain rule.
- Why are activation functions needed? Without a nonlinear activation, stacked layers collapse into one linear map, so the network could not represent nonlinear functions.
Chapter 26: Deep Learning
Part V: Regression · Difficulty: Hard · Key topics: recurrent neural network, backpropagation through time, LSTM, forget gate, convolution, padding, stride, pooling, dropout, regularization
This is the longest chapter and covers three families of deep models. Recurrent neural networks add feedback connections to handle sequences, are trained by unrolling them in time, and can be made bidirectional. Because RNNs suffer from vanishing and exploding gradients, the chapter introduces gated networks, starting with a forget gate and then the full LSTM with its internal memory. Convolutional neural networks are treated next, with convolutions, padding and striding, pooling, deep CNN architectures and their training. The last section covers regularization, including L2 penalties and dropout.
Key Points:
- An RNN reuses the same weights at every time step, so the unrolled network has shared parameters.
- Backpropagation through time is ordinary backpropagation on the RNN unrolled across the time steps.
- Gates (forget, input and output) in an LSTM control what information is kept, updated and passed on, which eases the vanishing gradient problem.
- A convolutional layer applies the same small filter across positions, so it has far fewer weights than a fully connected layer.
- Padding keeps the output size from shrinking, striding skips positions, and pooling (such as max-pooling) summarizes small regions.
- Dropout randomly sets a fraction of neuron values to zero during training so the network does not rely on any single neuron.
Memory Tip: RNN = memory through time, CNN = the same filter in many places, dropout = train with some neurons switched off. Each solves a different problem.
Common Mistake: Expecting this chapter to cover current practice such as transformers, attention-based models or modern training libraries. It stops at RNNs, LSTMs and CNNs.
Important Questions:
- Why are LSTMs preferred over simple RNNs? Gated memory lets information and gradients flow over many time steps, which reduces the vanishing gradient problem that stops plain RNNs learning long-range dependencies.
- What are padding, stride and pooling in a CNN? Padding adds border values so the output stays large, stride is the step size of the filter, and pooling aggregates a small region into one value to reduce size.
Chapter 27: Regression Evaluation
Part V: Regression · Difficulty: Hard · Key topics: sum of squared errors, total sum of squares, R squared, standard error, hypothesis testing, t distribution, standardized residuals, geometric approach
The final chapter asks how well a regression model fits and which predictors really matter. For univariate regression it decomposes the total scatter into explained and unexplained parts, defines goodness of fit with the coefficient of determination, and tests whether the slope differs from zero using the t distribution and p-values. It also examines standardized residuals to check the normal error assumption. The multiple regression section repeats the decomposition and hypothesis tests for several predictors and gives a geometric approach to the same tests, based on the projections used in Chapter 23.
Key Points:
- The total sum of squares splits into the part explained by the model and the part left in the residual errors.
- R squared is the fraction of the variation in the response that the model explains.
- A hypothesis test on a regression coefficient checks whether the predictor has a real effect (null hypothesis: the true weight is zero).
- Standardized residuals should look like draws from a normal distribution if the model assumptions hold.
- For multiple regression the same tests are interpreted through the geometry of projections onto the predictor space.
Memory Tip: Total variation = explained + unexplained. R squared is simply the explained share of the total.
Common Mistake: Treating a high R squared as proof that the model is correct. It does not say whether the assumptions hold or whether the predictors are meaningful, so check residuals and tests as well.
Important Questions:
- What does R squared measure? It measures the proportion of the total variation in the response that is explained by the regression model, from 0 (nothing) to 1 (everything).
- How do you test whether a predictor affects the response? State the null hypothesis that its true weight is zero, compute the test statistic from the estimated weight and its standard error, and compare it with the t distribution to get a p-value.
How to Study This Book
The full text is free in the authors’ online reader, 27 chapters in five parts, but there is no PDF to download and the text may be used for personal online reading only. Keep that in mind when you plan your study: you will read it on screen, so work chapter by chapter and keep your own notes. The authors say the chapters are mostly self-contained, but a first course should cover the foundations in Part I, and the short overview at the start of each part tells you what to expect. They also say that the kernel methods chapter (Chapter 5) should come before the later chapters that use kernels: Section 7.3, Section 13.2, Section 20.2, Section 21.4 and Section 23.5.
Be honest about the prerequisites, because this is a mathematical book. You need linear algebra (vectors, matrix products, eigenvalues and eigenvectors, projection), basic multivariable calculus (partial derivatives and gradients, which every learning algorithm in Parts IV and V uses) and probability and statistics (random variables, the normal distribution, maximum likelihood, hypothesis tests). The preface says that important concepts are explained when first met, with detailed steps and derivations, so it is an introduction, but it is not an easy read. If your probability is rusty, start with Think Stats and Mathematics for Computer Science, and use Calculus Volume 3 for partial derivatives and gradients.
For a one-semester course in data mining or machine learning, a sensible path is: Chapter 1 and Chapter 2 quickly, a skim of Chapter 3, then Sections 7.1 and 7.2 on PCA, Sections 8.1 to 8.3 on frequent itemsets and association rules, Sections 13.1 and 13.3 on K-means and EM, Chapter 14 on hierarchical clustering, Section 15.1 on DBSCAN and the first parts of Chapter 17 for evaluating clusterings. For classification read Chapters 18 and 19, then Chapter 5 followed by Chapter 21 on SVMs, and Chapter 22 on evaluation and ensembles. Finish with Chapters 23 and 24 on linear and logistic regression. On a first pass you can leave out Chapters 4, 6, 10, 11 and 16, and the proofs inside the long derivations.
For a pattern mining course, Part II (Chapters 8 to 12) is a self-contained sequence. Chapters 8 and 9 are the core, and Chapter 12 is where the statistics of pattern assessment lives. Chapters 10 and 11 on sequences and graph patterns are the hardest in the part, with suffix trees and canonical DFS codes, so give them extra time. If your interest is neural networks, read Chapter 23 and Chapter 24 first, because Chapter 25 presents regression and logistic regression as one-neuron networks and then builds the multilayer perceptron, and Chapter 26 follows with RNNs, LSTMs and CNNs. Chapter 27 is a statistics-heavy chapter that matters most for regression courses and can be postponed.
Chapters 4, 5 and 16 suit students who like graphs and linear algebra: network centrality and models, kernels, and spectral clustering. Chapter 6 on high-dimensional geometry is worth reading once for intuition, since it explains why distances and densities misbehave in many dimensions, but it is not needed to follow later chapters. A good habit is to implement what you read. The authors suggest writing the algorithms yourself in Python or R, and the book itself contains no program code. The companion site at dataminingbook.info lists slides, lecture videos, datasets and descriptions of implementation projects, and it offers a solutions manual to instructors only, so the exercises here have no published answers.
Know the limits before you rely on it. The book is from 2020 and stops at feed-forward networks, RNNs, LSTMs and CNNs, so there is nothing on transformers, attention models or autoencoders, and the only boosting method is AdaBoost. Decision tree pruning is mentioned only as a pointer to other references, and there is no practical treatment of missing values, feature engineering or modern libraries such as scikit-learn. The clustering, frequent pattern, kernel and regression chapters have not dated, and neither have the evaluation methods in Chapter 22, so use this book for the fundamentals and pair it with a current practical text for tools.
Used In These Programs
This book is used for Data Mining and Machine Learning courses in: BS Data Science · BS Computer Science. Browse all Data Mining books, all Machine Learning books or all Computer Science books.
Who Should Read This
This book is written for senior undergraduate and graduate students in BS Data Science, BSCS and MS programs who want to understand how data mining and machine learning algorithms work, not only how to call them. It suits a core data mining or machine learning course from about the fifth semester, a pattern mining or clustering elective, and self-study for anyone with a good grounding in linear algebra and probability. It is also a good reference for the derivations behind PCA, EM, SVMs, logistic regression and backpropagation. It is not a first programming book, and it is not a practical guide to tools such as pandas or scikit-learn, so beginners should first read Think Python, then Think Stats for exploratory statistics in code and Think Bayes for the probabilistic thinking that Chapter 18 builds on.
Applicable Universities
This book is useful for students at Pakistani universities offering BS Data Science, BS Computer Science and MS programs with a data mining, machine learning, data science or pattern recognition course, including Punjab University, Virtual University, COMSATS, FAST, UET, NUST, and other HEC-recognized institutions.
Official Copy of Data Mining and Machine Learning
The authors offer the complete Second Edition free in the online reader on their companion site, for personal online use. There is no PDF of the book. Click the button below to open the reader on dataminingbook.info and read it chapter by chapter. The print and e-book editions are sold by Cambridge University Press.
→ Visit Official PageFAQs
Is Data Mining and Machine Learning by Zaki and Meira free?
Yes, to read online. The authors provide the complete Second Edition in an online reader at dataminingbook.info, and the index page says it is provided for personal online use. It is not an open-licence book: the copyright page says no part may be reproduced without the written permission of Cambridge University Press, and the site says unauthorized distribution is not allowed. There is no PDF download, so use the official reader instead of reposted files.
Which edition is this?
This page covers the Second Edition, published by Cambridge University Press in March 2020 (ISBN 978-1-108-47398-9). The first edition appeared in 2014 as Data Mining and Analysis. The new edition adds a full part on regression with linear and logistic regression, neural networks and deep learning, updates several other chapters and fixes known errata. The site keeps an errata page for later corrections.
How many chapters and exercises does it have?
There are 27 chapters in five parts, plus a preface and an index, about 770 printed pages. Every chapter ends with exercises, more than 180 numbered questions in all, many of them calculations on small tables. The book does not print solutions, and the authors give a solutions manual to instructors only, on request from an academic address.
Is it good for complete beginners?
No. The preface calls it an introductory text with detailed derivations, but it expects linear algebra, multivariable calculus and probability, and it uses vector and matrix notation throughout. It contains no program code. Students who are new to data analysis should first build a base with a statistics-in-Python book, then come back and start with Parts I and IV.
Does it cover deep learning, neural networks and SVMs?
Yes. Chapter 21 explains support vector machines in detail, including the soft margin and kernels. Chapter 25 covers neurons, multilayer perceptrons and backpropagation, and Chapter 26 covers recurrent networks, LSTMs, convolutional networks and dropout. It does not cover transformers or attention models, so it is a foundation for deep learning and not a survey of current architectures.
Is it still current in 2026?
The core is: PCA, frequent pattern mining, K-means, EM, DBSCAN, spectral clustering, decision trees, SVMs, regularized regression, backpropagation and evaluation methods have not changed in substance. The gaps come from its 2020 date: nothing on transformers, attention or autoencoders, boosting limited to AdaBoost, and no tools or libraries. Use it for the fundamentals and a newer practical text for current tooling.
Related Books
- Think Stats: Exploratory Data Analysis in Python – Allen B. Downey
- Think Bayes: Bayesian Statistics in Python – Allen B. Downey
- Mathematics for Computer Science – Lehman, Leighton & Meyer (MIT OCW)
- Think Python – Allen B. Downey (3rd Edition)
Zaki and Meira show where PCA, K-means, SVMs and backpropagation come from, with the algebra and geometry behind each, in one free book. Browse more Computer Science books for the rest of your semester.
Data Mining and Machine Learning: Fundamental Concepts and Algorithms, 2nd Edition by Mohammed J. Zaki and Wagner Meira Jr., Cambridge University Press, March 2020. Copyright Mohammed J. Zaki and Wagner Meira Jr. 2020; the authors provide the book in an online reader for personal online use and no open licence applies. Official source: https://dataminingbook.info/. 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.
