Mahout Java API to find centroid of clusters generated using k-means

752 views Asked by At

I had clustered a list of points into k clusters using the k-means algorithm in Mahout. How do we find the centroid of a particular cluster? Is there any java Mahout API calls for finding this?

1

There are 1 answers

1
sunitha On

i could find centroid using the following code.

SequenceFile.Reader reader1 = new SequenceFile.Reader(fs, new Path( "output/clusters-1/part-r-00000"), conf);

    IntWritable key1 = new IntWritable();
    ClusterWritable value1 = new ClusterWritable();
    while (reader1.next(key1, value1)) {

        System.out.println(value1.getValue().getCenter()+ " ------------ "
                + key1.toString());
    }
    reader1.close();