I took some code I had for performing K-means clustering and made it into a proper class. I also found Dan Stowell's KMeans quark and borrowed some concepts from that one. My version works slightly different and uses
RedVectors of any dimension.
The class is part of my redUniverse quark and the best way to install it is as always to from within SuperCollider type...
Quarks.install("redUniverse"); and then recompile. A help file and simple examples are included but I hope to write more elaborate demonstrations of this later on.
This is a screenshot from the example in the
RedKMeans help file. 1000 random points are categorised into 5 groups/clusters. The bigger circles are the 5 mean points/centroids.
Also, see 190-kmeans.scd for an example running in realtime.