k-nearest-neighbor classification and k-means - an interactive example

· by

Contents

When the circle has exactly the same number of blue / green dots in it, it will be green.

When you move the mouse over the box, everything will be calculated and drawn again. This leads to flickering with k-means, as k-means includes a random choice of cluster centers.

Changelog

Version Change
2.2 Cluster centers have the same color as the clustered points; when one cluster has no points (and there are at least as many points as clusters) everything gets recalculated
2.1 users can now specify an arbitrary number of classes; ctrl-key change of class was removed; added hints to configuration options
2.0 k-means implemented
1.0 k-nearest neighbor implemented

Code is on GitHub. You may use it for free, but you should add a link to this article.

See also

One interesting setting for k=2
One interesting setting for k=2
k-means: Good vs. Bad
k-means: Good vs. Bad