Created
June 27, 2021 14:27
-
-
Save orhermansaffar/518ae0a7dcab2d02579dc41e79ae2b41 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
def chooseBestKforKMeans(scaled_data, k_range): | |
ans = [] | |
for k in k_range: | |
scaled_inertia = kMeansRes(scaled_data, k) | |
ans.append((k, scaled_inertia)) | |
results = pd.DataFrame(ans, columns = ['k','Scaled Inertia']).set_index('k') | |
best_k = results.idxmin()[0] | |
return best_k, results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment