Created
May 23, 2020 00:41
-
-
Save maskaravivek/37359884219d9a925d640c5396201f55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
K = 6; | |
color = lines(K); | |
[idx, C, SSE] = kmeans(X, K, 'Distance', 'sqEuclidean', 'Replicates', 10); | |
totalSSE = sum(SSE); | |
fprintf('SSE using K-means is %d \n', totalSSE); | |
figure | |
gscatter(X(:,1),X(:,2),idx,color(1:K,:)) | |
hold on | |
plot(C(:,1),C(:,2),'+k', 'MarkerSize', 8, 'LineWidth', 3) | |
legend('Cluster 1','Cluster 2','Cluster 3','Cluster 4','Cluster 5','Cluster 6','Cluster Centroid') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment