2 ms·
K-means is a fairly easy algorithm to implement. You just split your data depending on how many clusters you want, calculate the distance of every point to each
by physcab 17y ago
K-means is a fairly easy algorithm to implement. You just split your data depending on how many clusters you want, calculate the distance of every point to each cluster, assign, re-split, re-calculate, re-assign until some convergence criteria is met.
There are a variety of implementations that speed this process up. One is canopy clustering which allows you specify which clusters the points will check with (ie checking with all the clusters takes a while, but canopies can limit the search). You can also try different distance metrics such as the triangle inequality.
There should be lots of implementations online, specifically for Matlab which you can port over to another language if you wanted. It's one of the most widely used and most useful clustering algorithms and often provides initialization for lots of other algorithms such as Expectation Maximization (EM).
This link comes to mind: http://cseweb.ucsd.edu/~elkan/fastkmeans.html http://cseweb.ucsd.edu/~elkan/fastkmeans.html