Posts Tagged ‘algorithm’

Kennard Stone algorithm in C++

Monday, February 4th, 2008

This algorithm can be used for the selection of a training set. It works in the following way: (see this PDF for a graphical depiction of how this algorithm works)

Find the two points most separated in the training set
For each candidate point, find the smallest distance to any object already selected
Select that point for the training set which has the largest of these smallest distances
As described above, this algorithm always gives the same result, due to the two starting points which are always the same. Alternatively, one could choose two random points to start with. In that way, different training sets can be obtained.

The source code can be downloaded here, it is provided as a gzipped tar file. The code is far from being perfect, but it does the job. If you make any modifications to the code please let me know so that I can include them on this page here and in the original code. There are some comments in the source files that should explain how the program works. If you have any questions don’t hesitate do drop me an email.