[comp.ai] Clustering code

pet111@park.bu.edu (Frank Petrucci) (02/28/91)

John A. Hartigan has a book called Clustering Algorithms (1975), New
York: Wiley, that has a k-means description(ch.4) and a program that
seems to be written in BASIC.
Algorithm:
1. take an initial partition, of M inputs into K clusters.
(the # of clusters known in advance)

2 Take the 1st input, see whether the error would be decreased by
moving the input to another cluster.  If so, move to the best such
cluster, and adjust calculations of the means and the error.

3 repeat step 2 for each input.

4. Go back to 2, repeat until steps 2-3 yield no changes.
------
The cluster center is based upon an average of all its members.
error is based on the input's distance from the cluster center.