Why spectral clustering beats K-means on curved data
K-means assumes clusters are round, so it cuts the two moons dataset straight down the middle. Spectral clustering reads the data as a graph instead: build the Laplacian, take its smallest eigenvectors, cluster in that space. With NumPy code and notes on tuning gamma.