Guest User

Untitled

a guest
Dec 13th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. Sum_of_squared_distances = []
  2. K = range(1,15)
  3. for k in K:
  4. km = KMeans(n_clusters=k)
  5. km = km.fit(data_transformed)
  6. Sum_of_squared_distances.append(km.inertia_)
  7. plt.plot(K, Sum_of_squared_distances, 'bx-')
  8. plt.xlabel('k')
  9. plt.ylabel('Sum_of_squared_distances')
  10. plt.title('Elbow Method For Optimal k')
  11. plt.show()
Add Comment
Please, Sign In to add comment