K-Means initialization (newbie question)

dupolas
dupolas New Altair Community Member
edited November 5 in Community Q&A
Hi All,

being a newbie to both data mining and Rapidminer I run into a question with regards to the k-means clustering algorithm.

First of all, from my theory book (Introduction to datamining by Tan & Steinbach) I learned that choosing the initial centroids for k-means is essential for the success of the algorithm. With the examples in the book, I understand that. But I would like to learn how to do this in practice using rapidminer.

Is there a way to set the initial centroids? I don't see any attribute for it on the k-means component.

Am I misunderstanding theory? Is this something rapidminer just doesn't support (and thus does random initialization)

Another question is whether RapidMiner is using Euclidean distance, Manhattan distance or another distance algorithm (and if this can be influenced?)

Regards,

Geoffrey
Tagged:

Answers

  • wessel
    wessel New Altair Community Member
    Hey,

    @ option to set initial clusters yourself
    I don't think there is.
    But since RM is open source it is very easy to modify the code.
    Here is the source of k-means:
    http://pastebin.com/TvGxrwdJ

    Within source of public class CentroidClusterModel extends ClusterModel {
    for (int i = 0; i < k; i++) {
    centroids.add(new Centroid(dimensionNames.size()));
    }

    Please also read: http://rapid-i.com/content/view/25/72/lang,en/




    @ Theory
    I think random initializations are fine.
    You should simply do multiple runs with random initializations.
  • IngoRM
    IngoRM New Altair Community Member
    Hi,

    Another question is whether RapidMiner is using Euclidean distance, Manhattan distance or another distance algorithm (and if this can be influenced?)
    For k-Means, Euclidean distance is used. This is necessary in order to perform the cluster optimization in O(n log n) runtime and can hence not be changed. If you want to use other distance functions, you could use k-Medoids. This allows for all distance functions but is slightly slower and runs in O(n*n).

    Cheers,
    Ingo