MoonSay /Tutorials/Machine Learning Interview #3
Contents
  1. 01Introduction
  2. 02What clustering is
  3. 03K-means
  4. 04Choosing K, and where K-means fails
  5. 05Gaussian mixture models and the EM algorithm
  6. 06Dirichlet process mixtures
  7. 07DBSCAN
  8. 08Hierarchical clustering
  9. 09Spectral clustering
  10. 10Putting it all together
  11. 11Interview questions and model answers
  12. 12Summary
  13. References
Clustering Algorithms/Chapter 12 of 12

12Summary

  • Clustering groups unlabeled points; every method is a definition of “belonging together” plus an algorithm. Standardize features; there is no single correct answer.
  • K-means: minimize J=\sum_i\|x_i-\mu_{c_i}\|^2; Lloyd alternates nearest-centre assignment and \mu_k=\bar x_k; converges to a local minimum; Voronoi cells are convex; k-means++ seeds with P(x)\propto D(x)^2 and gives \E[J]\le8(\ln K+2)J_{\mathrm{opt}}.
  • Choosing K: elbow of J; silhouette s=(b-a)/\max(a,b); gap statistic; BIC for mixtures.
  • Gaussian mixture: p(x)=\sum_k\pi_k\mathcal N(x\mid\mu_k,\Sigma_k); E step \gamma_{ik}\propto\pi_k\mathcal N(x_i\mid\mu_k,\Sigma_k); M step weighted means, covariances and \pi_k=N_k/n; the likelihood never decreases; K-means is the limit \Sigma_k=\epsilon I, \epsilon\to0.
  • Dirichlet process mixture: stick-breaking \beta_k\sim\mathrm{Beta}(1,\alpha), \pi_k=\beta_k\prod_{j<k}(1-\beta_j), \E[\pi_k]=\frac{1}{1+\alpha}(\frac{\alpha}{1+\alpha})^{k-1}; expected clusters \approx\alpha\ln(1+n/\alpha); unused components die out.
  • DBSCAN: core point if |N_\varepsilon(x)|\ge minPts; clusters are connected core points plus border points; the rest is noise; choose \varepsilon from the sorted k-distance graph; HDBSCAN for varying densities.
  • Hierarchical: merge the closest clusters until one remains; single, complete, average or Ward linkage (\Delta=\frac{|G||H|}{|G|+|H|}\|\bar x_G-\bar x_H\|^2); cut the dendrogram.
  • Spectral: similarity graph, L=D-W, f^\top Lf=\frac12\sum_{ij}w_{ij}(f_i-f_j)^2; zero eigenvalues count components; K-means on the smallest eigenvectors; a relaxed normalized cut; the graph matters.
  • Connections: K-means is the hard, small-variance limit of a GMM, and Lloyd and EM are both coordinate-wise optimization; a GMM with known labels is QDA; Ward is a greedy, bottom-up K-means; single linkage is the minimum spanning tree, and DBSCAN with minPts =2 is single linkage cut at height \varepsilon; spectral clustering is K-means after a relaxed graph cut.