Spectral Clustering: X Through The Parameter W 0. The Resulting
Spectral Clustering: X Through The Parameter W 0. The Resulting
nb_samples = 2000
km = KMeans(n_clusters=2, random_state=1000)
sc = SpectralClustering(n_clusters=2, affinity='rbf', gamma=2.0,
random_state=1000)
Y_pred_km = km.fit_predict(data)
Y_pred_sc = sc.fit_predict(data)
As you can see, K-means partitions the dataset with two balls
along the x-axis, while spectral clustering succeeds in
separating the two sinusoids correctly. This algorithm is very
powerful whenever both the number of clusters and the
dimensionality of X are not too large (in this case the
eigendecomposition of the Laplacian can become very
computationally expensive). Moreover, as the algorithm is
based on a graph cutting procedure, it's perfectly suited when
the number of clusters is even.