Monday, October 31, 2011

k-means and Octave

In the lecture on unsupervised learning on the Stanford's AI online course, there is the presentation of the k-means algorithm.

The algorithm is simple:

  • Bind each data point to the closest centroid:

  • Adjust each centroid's position to the mean of its bound data points:

  • And  cycle through these until there is no more change

Here is a quick example with random points:

The code is in my github k-means-octave repository.