Demo: k-means
Notes
Click on the grid to create some data points.
Double-click to create a bunch of points at once
The following functions are available. You can also call the same functions through the JavaScript console.
k =
-- set the value of k to NUMBER. 3 by default. Do not set it to more than 10, I have only defined that many colours!
initialCentroids
-- randomly place k centroids
assignToCentroids
-- assign each data point to its nearest centroid
updateCentroids
-- update the centroids to the average of all points in this cluster
kmeans
-- Combined. Run
initialCentroids
once, followed by
assignToCentroids
and
updateCentroids
in a loop until nothing changes.