K-Means Walk-Through Example
Practice the k-means algorithm with a step-by-step walkthrough example in this lesson.
-means algorithm
For a given dataset and value of , -means clustering has the following steps:
-
Choose some value of such that , if it’s not given already.
-
Choose number of centroids, randomly.
-
Find the similarity score of each data point with respect to each centroid.
-
Based on the similarity score, assign each data point its centroid.
-
From these new groupings, find new centroids by taking the mean of all data points of a cluster.
-
Repeat steps 3 to 5 until the difference between old and new centroids is negligible.
If the steps above seem unclear, don’t worry. We’re going to show each step in an example with an illustration.
Dry running the example
Let’s say we have the following dataset:
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy