Chapter 10

Clustering

Clustering groups inputs using a chosen dissimilarity and objective. There is no target label to minimise error against. Feature scaling, distance choice and the requested number of clusters affect the result.

10.1 K-means objective and geometry

Past papers · DA 2024–2026 (3 papers): 1 question, 1 mark

Let C1,…,Ck\mathcal C_1,\ldots,\mathcal C_k partition nn observations, with nonempty clusters and centres μ1,…,μk\boldsymbol\mu_1,\ldots,\boldsymbol\mu_k. Standard k-means uses squared Euclidean distance.

Lloyd iteration alternates these steps. The objective cannot increase in either step, but the final solution need not be global. Initialise centres, assign points, recompute means and repeat until assignments or objective stop changing. Ties and empty clusters need a specified convention; an empty cluster has no mean. Multiple initialisations can give different local optima. The globally optimal objective cannot increase when kk increases, but separately run local solutions need not show that monotonicity.

A point on such a segment is assigned to that cluster if it is a data point and the tie convention is consistent with the region; arbitrary reassignment of tied boundary points can break the statement about assigned clusters. The convex-region result does not mean the finite set of observed points contains every segment point. K-means is sensitive to outliers because errors are squared; it works most naturally with compact, roughly spherical groups on the chosen scale.

10.2 K-medoid representatives

A medoid must be an observed object. It therefore applies even when inputs are represented only by a dissimilarity matrix. Dissimilarities need not come from Euclidean coordinates.

MethodRepresentativeObjective contribution
K-meansArithmetic mean, possibly unobservedSquared Euclidean distance
K-medoidOne observed objectChosen dissimilarity

Under absolute distance on a line, an observed median minimises one-cluster medoid cost. A medoid is not generally the point nearest the arithmetic mean. It often resists isolated extremes better than a squared-error mean, but robustness depends on the dissimilarity.

10.3 Hierarchical merging and splitting

Past papers · DA 2024–2026 (3 papers): 3 questions, 5 marks

Agglomerative (bottom-up) clustering starts with singleton clusters and repeatedly merges the closest pair. Divisive (top-down) clustering starts with all observations together and recursively splits a selected cluster. A top-down procedure must specify how the cluster and split are chosen; it is not uniquely determined by the word “divisive”.

To execute a specified divisive rule, select a splittable cluster, partition its observations by that rule, replace it by the resulting children, and repeat to the requested cluster count or stopping condition. Repeated two-way k-means splits are one possible divisive scheme. A divisive hierarchy is generally not the reverse of an agglomerative hierarchy; their local choices solve different subproblems.

Single linkage can chain groups through intermediate points; complete linkage is controlled by the farthest pair and tends to resist such chains. The first agglomerative merge is a closest pair of observations for all three rules, since all clusters initially are singletons. Equal minima can give multiple valid merge orders.

A dendrogram records merges and merge dissimilarities. With binary merges, nn observations need n−1n-1 merges to form one cluster; stopping after n−kn-k merges leaves kk clusters. Cut the dendrogram at a specified height and count the connected groups, handling equality at merge heights explicitly. For single linkage, a cut at threshold hh gives the connected components of the graph with edges between pairs having d≤hd\le h; this is also obtained by cutting a minimum spanning tree's edges above hh.

Single-linkage hierarchy for four original observations; merge height is a dissimilarity.Single-linkage hierarchy for four original observations; merge height is a dissimilarity.

Last-minute recall

  • K-means minimises squared Euclidean error and updates arithmetic means.
  • Each Lloyd step is nonincreasing, but a global optimum is not guaranteed.
  • Fixed-centre nearest regions are convex, with boundary ties needing care.
  • K-medoids uses observed representatives and the stated dissimilarity.
  • Agglomerative merges; divisive splits.
  • Single linkage takes a minimum; complete takes a maximum.
  • Average-linkage updates weight by cluster size.
  • A merge order can be nonunique when distances tie.

Revise offline: the whole Machine Learning handbook as one PDF

42 pages · 1.8 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections