#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
🔵 FREE · INTERACTIVE

K-Means Clustering Visualizer: Watch the Algorithm Find Groups

Click to add points, pick k, and see each assign-and-update step animate.

  • 🖱️ Click to add points
  • 🎞️ Step-by-step animation
  • 📉 Inertia for the elbow method

How to use the K-Means Clustering Visualizer

  1. 1. Add pointsClick the board, edit the list, or press Random blobs.
  2. 2. Choose k and a seedPick how many clusters to find and a seed for the start.
  3. 3. Run k-meansWatch the centres move until nothing changes, then read the summary.

How k-means works

k-means repeats two steps until the clusters stop changing:

  1. Assign every point to its nearest centre (Euclidean distance).
  2. Update each centre to the mean of the points assigned to it.

For example, if a cluster holds (1, 1), (2, 1) and (1, 2), its new centre is ((1 + 2 + 1) ÷ 3, (1 + 1 + 2) ÷ 3) = (1.33, 1.33). The algorithm minimises inertia, the sum of squared distances from points to their centres. The default board has 24 points in three clear groups, and with k = 3 the tool finds cluster sizes of 8, 8, 8.

Things to try

  • Change the seed. Starting centres are chosen with k-means++, which spreads them out, but a different start can still end in a different answer on messy data.
  • Run k = 2 to 6 and note the inertia each time. Where the drop flattens out, the elbow, is a reasonable k.
  • Make odd shapes like a ring or a long strip. k-means assumes round, similar-sized clusters and splits these badly; DBSCAN suits them better.
  • Add an outlier far away and watch it drag a centre.

In Python this is KMeans(n_clusters=3, n_init=10).fit(X) from scikit-learn, which runs several seeds and keeps the best. Always scale features first, because k-means uses raw distances; see the normalization calculator. Compare with a supervised method in the KNN visualizer.

Frequently asked questions

Can I use the keyboard instead of clicking?

Yes. Type points into the list as x, y per line; the board updates as you type.

Why do I sometimes get an empty cluster?

If no point is nearest to a centre, it keeps its old position. Try another seed or a smaller k.

Is the K-Means Clustering Visualizer free?

Yes, the K-Means Clustering Visualizer is free. The first time you run k-means for the first time, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools