Last active
May 3, 2019 19:52
-
-
Save karamanbk/3f0ef308a44ac3dccf768b3053f88e1e 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
from sklearn.cluster import KMeans | |
sse={} | |
tx_recency = tx_user[['Recency']] | |
for k in range(1, 10): | |
kmeans = KMeans(n_clusters=k, max_iter=1000).fit(tx_recency) | |
tx_recency["clusters"] = kmeans.labels_ | |
sse[k] = kmeans.inertia_ | |
plt.figure() | |
plt.plot(list(sse.keys()), list(sse.values())) | |
plt.xlabel("Number of cluster") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment