Search code examples
weka

Clustering initialization


How do you set clustering initialization method?

I found that besides random initialization you can select from a couple of more methods, such as k-means++ and farthest first.

I found that you can use the following method for that:

clusterer.setInitializationMethod(new SelectedTag);

Now, I'm really confused by this SelectedTag. What does it represent and how to use it? More specifically, how to specify k-means++ or farthest first as initialization methods?

Thanks


Solution

  • I found the solution, here is what needs to be done:

    clusterer.setInitializationMethod(new SelectedTag(SimpleKMeans.KMEANS_PLUS_PLUS, SimpleKMeans.TAGS_SELECTION));
    

    If you look at SimpleKMeans you will see that it has the following static members:

    static int  CANOPY 
    static int  FARTHEST_FIRST 
    static int  KMEANS_PLUS_PLUS 
    static int  RANDOM 
    static Tag[]    TAGS_SELECTION
    

    And this is how you use them. You can pass any distance identifier you need.

    Cheers!