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
 
Kmeansoperator= (Kmeans const &)=default
 
Kmeansoperator= (Kmeans &&)=default
 
 Kmeans (int64_t seed)
 
 Kmeans (int64_t seed, int64_t iters)
 
template<typename Cluster , typename Clusterable >
std::vector< Clustercluster (std::vector< Clusterable > const &cbls, int64_t nclusters)
 Computes Clusters from Clusterables. More...
 

Constructor & Destructor Documentation

◆ Kmeans() [1/5]

mpqc::math::clustering::Kmeans::Kmeans ( )
default

◆ Kmeans() [2/5]

mpqc::math::clustering::Kmeans::Kmeans ( Kmeans const &  )
default

◆ Kmeans() [3/5]

mpqc::math::clustering::Kmeans::Kmeans ( Kmeans &&  )
default

◆ Kmeans() [4/5]

mpqc::math::clustering::Kmeans::Kmeans ( int64_t  seed)
inline

Constructor to Change the initial seed for Kmeans++

Parameters
seedint64_t value to set the seed used in k-means++

◆ Kmeans() [5/5]

mpqc::math::clustering::Kmeans::Kmeans ( int64_t  seed,
int64_t  iters 
)
inline

Constructor to change the initial seed for Kmeans++ and the maximum number of iterations used in clustering

Parameters
seedint64_t value to set the seed used in k-means++
itersint64_t value to set the maximum number of iterations used in Lloyd's algorithm.

Member Function Documentation

◆ cluster()

template<typename Cluster , typename Clusterable >
std::vector<Cluster> mpqc::math::clustering::Kmeans::cluster ( std::vector< Clusterable > const &  cbls,
int64_t  nclusters 
)
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
cblsA vector of Clusterables to be clustered. Requirements are listed below
nclustersint64_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]

Kmeans& mpqc::math::clustering::Kmeans::operator= ( Kmeans &&  )
default

◆ operator=() [2/2]

Kmeans& mpqc::math::clustering::Kmeans::operator= ( Kmeans const &  )
default

The documentation for this class was generated from the following file: