Created
March 12, 2023 07:18
-
-
Save liliya2022/394f5fc820f73ab154cb6f8c751c9ae6 to your computer and use it in GitHub Desktop.
This file contains 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 | |
from sklearn.preprocessing import MinMaxScaler | |
from sklearn.preprocessing import LabelEncoder |
This file contains 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
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_) |
This file contains 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
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