K-mean clustering and Soft K-means clustering (octave)

(c) David J.C. MacKay | Lecture course | Book | Other demonstrations |


1. Hard K-means clustering, demonstrated in two dimensions. Introductory simple examples; then examples where the results do not look so good, showing a need for a probabilistic approach.

2. Soft K-means clustering. Radii of Gaussians visualized. Several versions of Soft K-means, and various pathological data sets.


This demonstration should work if you are running X-windows on a unix machine that has octave-2.0 and gnuplot.
More recent versions of octave (eg 2.1) may give problems.
If you have got octave and gnuplot on some other system (eg cygwin under Windoze), it may work.
A soft clustering algorithm at work

To run the demonstration:

  1. get the demonstration files (41K) by clicking here http / ftp
  2. unpack thus:
           tar zxvf kmeans.tar.gz
    This unpacks a load of files into a directory called kmeans and another directory called kmeansoft. [If there are any complaints about the clock time use tar zxvfm kmeans.tar.gz]
  3.        cd kmeans
  4. (optional) modify your X windows defaults so that the gnuplot colours and fonts come out right. (Execute this command on the machine running X windows.)
           xrdb -load Xdefaults.gnu
  5.  octave
    (Works fine with octave-2.0 but not with octave-2.1.33, which seems to have plotting bugs.)
  6. To run the demo:
           load 'DEMO'
    Select from a range of demonstrations. If you keep hitting return you will be taken through the sequence
  7. To run soft K-means, change to directory kmeansoft and run octave there.


David MacKay <mackay@mrao.cam.ac.uk>
Last modified: Sun Nov 30 08:50:02 2003