I have to get the means of a k-means clustering. currently I'm using the apache commons math library which implements a k-means plus plus clustering algorithm. do anybody know, if there is a simple way to get the means after the clustering with this library or have i to implement it by myself?
if not, can you explain me how to calculate it or give me a code example?
Asked
Active
Viewed 1,153 times
0

chef
- 75
- 1
- 12
2 Answers
1
The output of the clustering algorithm must at least contain the cluster assignments, i.e. which cluster each point belongs to. If you have that, then the k-means clustering cluster centers are simply given by the mean of the points that belong to each cluster.

user2566092
- 4,631
- 15
- 20
-
ok and if a point consists of several dimensions, the mean is calculated for every cluster like this: get all points of a cluster -> sum all values in a col (dimension) up -> divide by the number of points? – chef Apr 10 '14 at 21:01
-
Exactly, each dimension in the mean vector is the mean of the values in that dimension for all the cluster points, i.e. the sum of all the point values in that dimension for points belonging to the cluster, divided by the total number of points in the cluster. – user2566092 Apr 10 '14 at 21:16
0
The KMeansPlusPlusClusterer (package org.apache.commons.math3.ml.clustering, version 3.2+ ) returns a List of CentroidCluster objects. From a CentroidCluster you can get the cluster center (= mean of cluster points) by calling the getCenter() method.

T. Neidhart
- 6,060
- 2
- 15
- 38