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... download it with Quarks.checkoutAll; and then install via Quarks.gui; a helpfile 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 helpfile. 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.