KMeansClustering
KMeansClustering copied to clipboard
KMeans clustering in Eigen.
This is a c++ implementation of the K-Means clustering algorithm. It also includes the KMeans++ initialization algorithm.
Obtaining the code: Please be sure to: git clone --recursive
so that the submodules will also be checked out.
Example usage:
KMeansClustering::VectorOfPoints points = ... load data ... KMeansClustering kmeans; kmeans.SetK(2); // specify the number of clusters kmeans.SetPoints(points); kmeans.Cluster(); // Perform the clustering
// Get the membership of every point
std::vector
// Get all points ids with a particular membership (in this case, cluster 0)
std::vector
/** Get the points with a specified cluster membership. */ VectorOfPoints pointsInCluster0 = kmeans.GetPointsWithLabel(0);