Skip to content


Subversion checkout URL

You can clone with
Download ZIP
KMeans clustering in Eigen.
C++ CMake
branch: master

Fix bugs.

latest commit 79067c5610
David Doria authored

This is a c++ implementation of the K-Means clustering algorithm. It also includes the KMeans++ initialization algorithm.

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 labels = GetLabels();

// Get all points ids with a particular membership (in this case, cluster 0) std::vector pointIdsInCluster0 = kmeans.GetIndicesWithLabel(0);

/** Get the points with a specified cluster membership. */ VectorOfPoints pointsInCluster0 = kmeans.GetPointsWithLabel(0);

Something went wrong with that request. Please try again.