Skip to content

Instantly share code, notes, and snippets.

@Lakshmi-1212
Last active June 2, 2021 04:52
Show Gist options
  • Save Lakshmi-1212/0418c134dfb539f7001c812c58273a96 to your computer and use it in GitHub Desktop.
Save Lakshmi-1212/0418c134dfb539f7001c812c58273a96 to your computer and use it in GitHub Desktop.
K-Means Clustering
from sklearn.cluster import KMeans
# Create the KMeans object for 5 clusters and 50 iterations
kmeans = KMeans(n_clusters=4, 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