Created
September 17, 2018 16:51
-
-
Save ImadDabbura/3c7621d74b380e902aa836f74d859ce9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Run the Kmeans algorithm and get the index of data points clusters | |
| sse = [] | |
| list_k = list(range(1, 10)) | |
| for k in list_k: | |
| km = KMeans(n_clusters=k) | |
| km.fit(X_std) | |
| sse.append(km.inertia_) | |
| # Plot sse against k | |
| plt.figure(figsize=(6, 6)) | |
| plt.plot(list_k, sse, '-o') | |
| plt.xlabel(r'Number of clusters *k*') | |
| plt.ylabel('Sum of squared distance'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment