Skip to content

Instantly share code, notes, and snippets.

@liliya2022
Created March 12, 2023 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liliya2022/394f5fc820f73ab154cb6f8c751c9ae6 to your computer and use it in GitHub Desktop.
Save liliya2022/394f5fc820f73ab154cb6f8c751c9ae6 to your computer and use it in GitHub Desktop.
from sklearn.cluster import KMeans
from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import LabelEncoder
k_rng = range(1,10)
sse =[]
for k in k_rng:
km = KMeans(n_clusters = k)
km.fit(salary_story[['Total Salary Paid Rescaled', 'Home Price Rescaled']])
sse.append(km.inertia_)
plt.xlabel('K')
plt.ylabel('Sum of squared error')
plt.plot(k_rng, sse)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment