Skip to content

Instantly share code, notes, and snippets.

@jtemporal
Last active February 16, 2023 00:49
Show Gist options
  • Save jtemporal/be5d4be10f8ca657901e4512e0644a4a to your computer and use it in GitHub Desktop.
Save jtemporal/be5d4be10f8ca657901e4512e0644a4a to your computer and use it in GitHub Desktop.
def calculate_wcss(data):
wcss = []
for n in range(2, 21):
kmeans = KMeans(n_clusters=n)
kmeans.fit(X=data)
wcss.append(kmeans.inertia_)
return wcss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment