Contents
Clustering Algorithms/Chapter 10 of 12
10Putting it all together
10.1Same data, five definitions of a cluster
Figure 9 runs the five methods on three standardized data sets, as in the video. On well-separated round blobs every method is perfect. On elongated clusters the Gaussian mixture is perfect (1.00), spectral clustering good (0.91), DBSCAN finds the three clusters but calls 45 points noise (0.76), and K-means (0.51) and Ward (0.47), with their preference for round clusters, cut across. On the noisy moons DBSCAN is best (0.94), finding the moons and marking 9 points as noise, though it also makes a tiny third cluster; Ward (0.64), the Gaussian mixture (0.50), K-means (0.45) and spectral clustering with this graph (0.36) fail. No method wins everywhere: each wins where its definition of a cluster matches the data.
| K-means | Gaussian mixture | DBSCAN | Hierarchical | Spectral | |
|---|---|---|---|---|---|
| A cluster is | points near a centre | a Gaussian blob | a dense region | a branch of a merge tree | a well-connected piece of a graph |
| Needs | K | K (or \alpha for a DP) | \varepsilon, minPts | linkage, cut height | graph, K |
| Shapes | round, similar size | ellipses | any | depends on linkage | any connected shape |
| Assignment | hard | soft | hard, plus noise | hard, nested | hard |
| Outliers | pull the centres | widen components | labelled noise | single linkage chains | can bridge clusters |
| Cost | O(nKd) per iteration | O(nKd^2) per iteration | O(n\log n) to O(n^2) | O(n^2) to O(n^3) | eigenvectors, O(n^3) dense |
| Guarantee | local minimum of J | local maximum of \ln L | deterministic for core points | greedy | relaxation of a cut |
10.2A practical recipe
- Decide what “similar” means for the application, choose the features, and standardize them (or weight them deliberately).
- Start with K-means (k-means++, several restarts) as a fast baseline; look at the elbow and the silhouette over a range of K.
- Use a Gaussian mixture when clusters may be elongated or of different sizes, or when you need membership probabilities; choose K with BIC, or use a Dirichlet process prior.
- Use DBSCAN or HDBSCAN for irregular shapes, unknown K and outliers, especially in low-dimensional spatial data; choose \varepsilon from the k-distance graph.
- Use hierarchical clustering when you want structure at every scale or a picture of the relationships (dendrogram, heat map), for up to thousands of points.
- Use spectral clustering for connected but non-convex shapes, and check the result for different graphs.
- Validate: check stability across restarts, subsamples and parameters; inspect the clusters; and if some labels exist, compare with them using the adjusted Rand index.
10.3Common misconceptions
- “K-means finds the best clustering.” It finds a local minimum of J (Theorem 1); the global problem is NP-hard (Aloise et al., 2009). Use k-means++ and restarts.
- “K-means works for any cluster shape.” Its clusters lie in convex Voronoi cells and it prefers round clusters of similar size (Figure 3).
- “The elbow always shows the right K.” Often there is no clear elbow (Hastie et al., 2009, Figure 14.8); the silhouette, the gap statistic and BIC can disagree, and the application may fix K anyway.
- “Standardizing is always right.” It is a good default, but it gives noise features the same weight as informative ones, and it cannot undo correlations between features; Hastie et al. (2009, Section 14.3.3) show two well-separated groups that standardizing hides. Choosing the dissimilarity matters more than choosing the algorithm.
- “A clustering algorithm proves that clusters exist.” Every algorithm returns clusters, even for structureless data; a dendrogram always looks like a hierarchy (Hastie et al., 2009, Section 14.3.12). The gap statistic can answer “one cluster”.
- “A Gaussian mixture is always better than K-means.” It has many more parameters, needs more data, can degenerate, and still assumes ellipses.
- “DBSCAN has no parameters.” It needs no K, but \varepsilon and minPts matter a great deal, and one \varepsilon cannot fit clusters of very different densities.
- “A Dirichlet process finds the true number of clusters.” The number found depends on \alpha and on the component model; non-Gaussian clusters are split into several components.
- “Spectral clustering does not need any choices.” The similarity graph, its scale and K are choices, and the result can change completely with them (Section 9).
- “K-means and k-nearest neighbours are the same kind of method.” They share only the letter. K-means is unsupervised and finds K centres; k-NN is a supervised classifier or regressor that predicts from the labels of the k nearest training points, and it has no training step at all.
- “Cluster labels mean something by themselves.” Labels are arbitrary numbers; “cluster 2” in one run may be “cluster 0” in the next. Compare clusterings with permutation-invariant scores such as the adjusted Rand index (Hubert and Arabie, 1985).