Python exercise · about 5 minutes · free
K-Means: Find Customer Segments
No labels, just behaviour. Clustering finds natural groups, like casual players, regulars and whales.
K-means places k centres and assigns each point to the nearest one, repeating until stable. KMeans(n_clusters=3, n_init=10, random_state=0).fit(X); the groups are in .labels_. You still have to name and judge the clusters yourself.
Your quest: Cluster the players into 3 groups. Set
labels to the cluster label of each row.Try it now Runs in your browser. No sign-in needed. Ctrl+Enter to run.
Hint
labels = KMeans(n_clusters=3, n_init=10, random_state=0).fit(X).labels_Output appears here.