Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sum_of_squared_distances = []
- K = range(1,15)
- for k in K:
- km = KMeans(n_clusters=k)
- km = km.fit(data_transformed)
- Sum_of_squared_distances.append(km.inertia_)
- plt.plot(K, Sum_of_squared_distances, 'bx-')
- plt.xlabel('k')
- plt.ylabel('Sum_of_squared_distances')
- plt.title('Elbow Method For Optimal k')
- plt.show()
Add Comment
Please, Sign In to add comment