The workhorse of unsupervised learning. Watch centroids drift into place as k-means discovers the clusters hidden in unlabeled data.
k-Means ClusteringLive
Lloyd's algorithm · live
Controls
Presets
Lloyd's algorithm: assign each point to its nearest centroid, then move each centroid to the mean of its members. Repeat until stable. Try setting k different from the true cluster count.
★ Sign in to save this setupSave your tuned setup, or drop this simulation into your own site, docs, or course page.
How it works
k-means alternates two steps: assign every point to its nearest centroid, then move each centroid to the average of its assigned points. Repeating drives down the within-cluster variance (inertia) until it converges. Try setting k different from the true number of clusters to see how the choice matters.
✦
Ask the AI about this model
The math, the assumptions, real-world uses, or a code translation — explained for this exact simulation.
Yes. k-Means Clustering runs entirely in your browser using your device's own compute, so local use is free forever. You only pay Compute Tokens if you scale a job to the cloud.
Do I need to install anything?▾
No. Everything runs client-side in a modern browser — no downloads, no license, no account required to start.
Can I save or share my simulation?▾
Create a free account to save projects, and use a shareable embed or minted DOI to publish a live, interactive version anywhere.
How accurate are the results?▾
The solver uses established numerical methods, but results are for research and educational purposes and should be validated against experiment or professional review before you rely on them.