This project is implemented on a toy dataset for K-means algorithm and Spectral Clustering Algorithm with hierarchical clustering.
- Clone the repository using
git clone https://github.com/Abhishek-Nalawade/Spectral-Clustering-and-K-means
- Run the code Execute_comparison.py to compare both the methods for a certain number of classes (2, 4 or 8).
- Run the code plot_costs.py to plot the costs for both methods for 3 different nmuber of classes (2, 4 or 8) at once. The plot_costs.py code measures the cost as a result of the clusters formed using a criterion function.
It can be seen that for the dataset with circular trends Kmeans fails to cluster the data correctly whereas Spectral Clustering does it effectively
\
- The results obtained from K-means are not always consistent, because of the random initialization of the initial centroids the clusters formed can be different.