Created
June 17, 2019 06:41
-
-
Save KhyatiMahendru/2f7ff7c17ea13a28d5023f3aefa047e2 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
from sklearn.metrics import silhouette_score | |
sil = [] | |
kmax = 10 | |
# dissimilarity would not be defined for a single cluster, thus, minimum number of clusters should be 2 | |
for k in range(2, kmax+1): | |
kmeans = KMeans(n_clusters = k).fit(x) | |
labels = kmeans.labels_ | |
sil.append(silhouette_score(x, labels, metric = 'euclidean')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment