PPolySim OS

k-Means Clustering

The workhorse of unsupervised learning. Watch centroids drift into place as k-means discovers the clusters hidden in unlabeled data.

k-Means ClusteringLive

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.

▶ Run in Python

Data Inspector

Iteration0
Inertia0.00e+0
k4

Governing equation

Reading this result: k matches the 4 true clusters, so each centroid can settle onto one real group and inertia falls to a clean minimum.

Runs locally in your browser — free forever. Scale to the cloud when reality gets heavy.

or unlock everything with Pro →
★ Sign in to save this setup
Save 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.

More CS / AI simulations

Frequently asked questions

Is this k-means clustering tool really free?▾
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.