Skip to content

Instantly share code, notes, and snippets.

@Lakshmi-1212
Created June 1, 2021 05:32
Show Gist options
  • Save Lakshmi-1212/a2176245235fee2e70f0f5015838797c to your computer and use it in GitHub Desktop.
Save Lakshmi-1212/a2176245235fee2e70f0f5015838797c to your computer and use it in GitHub Desktop.
Apply the k-means algorithm
from sklearn.cluster import KMeans
# Create the KMeans object for 5 clusters and 50 iterations
kmeans = KMeans(n_clusters=5, max_iter=50)
# Fit the k-means algorithm on the given scaled players data
kmeans.fit(players_scaled)
# Assign the label to the output column in the original players
players[cluster_kmeans] = kmeans.labels_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment