mpqc::math::clustering::Kmeans Class Reference
Documentation
Kmeans is a class that performs k-means clustering.
Kmeans uses k-means++ for initialization of the clusters and then used Lloyd's algorithm to refine the clusters. Kmeans is considered converged when the positions of the centers stop changing or the maximum number of iterations was reached, during Lloyd's algorithm.
Public Member Functions | |
Kmeans ()=default | |
Kmeans (Kmeans const &)=default | |
Kmeans (Kmeans &&)=default | |
Kmeans & | operator= (Kmeans const &)=default |
Kmeans & | operator= (Kmeans &&)=default |
Kmeans (int64_t seed) | |
Kmeans (int64_t seed, int64_t iters) | |
template<typename Cluster , typename Clusterable > | |
std::vector< Cluster > | cluster (std::vector< Clusterable > const &cbls, int64_t nclusters) |
Computes Clusters from Clusterables. More... | |
Constructor & Destructor Documentation
◆ Kmeans() [1/5]
|
default |
◆ Kmeans() [2/5]
|
default |
◆ Kmeans() [3/5]
|
default |
◆ Kmeans() [4/5]
|
inline |
Constructor to Change the initial seed for Kmeans++
- Parameters
-
seed int64_t value to set the seed used in k-means++
◆ Kmeans() [5/5]
|
inline |
Constructor to change the initial seed for Kmeans++ and the maximum number of iterations used in clustering
- Parameters
-
seed int64_t value to set the seed used in k-means++ iters int64_t value to set the maximum number of iterations used in Lloyd's algorithm.
Member Function Documentation
◆ cluster()
template<typename Cluster , typename Clusterable >
|
inline |
Computes Clusters from Clusterables.
- Note
- may throw if the number of clusters does not make sense, i.e. is too small (<= 0) or too large (> # input Clusterables)
- Parameters
-
cbls A vector of Clusterables to be clustered. Requirements are listed below nclusters int64_t which specifies how many clusters are to be computed.
Requirements on Clusterable:
- non-intrusive center: returns a Vector3d
Requirements on Cluster:
- non-intrusive center: returns a Vector3d.
- non-intrusive set_center: takes Vector3d allowing for the cluster's center to be set manually, this is needed for initialization of the clusters with a guess.
- non-intrusive remove_clusterables: removes the clusterables in the cluster, but leaves the center and anything else, that is needed for determining distance to clusterables intact.
- non-intrusive attach_clusterable: which adds a new clusterable to the cluster. attach_clusterable should not update the center of the cluster since that must be done in a separate step in Kmeans
- non-intrusive update_center: Should use the cluster's current clusterables to update the center of the cluster, but should not remove any clusterables.
- begin and end functions which allow iteration over the elements of the cluster.
◆ operator=() [1/2]
◆ operator=() [2/2]
The documentation for this class was generated from the following file:
- mpqc/math/clustering/kmeans.h