A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Kmeans< Point > Class Template Referenceabstract

#include <genesis/utils/math/kmeans.hpp>

Detailed Description

template<typename Point>
class genesis::utils::Kmeans< Point >

Definition at line 91 of file utils/math/kmeans.hpp.

Public Member Functions

 Kmeans ()=default
 
 Kmeans (Kmeans const &)=default
 
 Kmeans (Kmeans &&)=default
 
virtual ~Kmeans ()=default
 
std::vector< size_t > const & assignments () const
 
Kmeansassignments (std::vector< size_t > const &value)
 
std::vector< Point > const & centroids () const
 
Kmeanscentroids (std::vector< Point > const &value)
 
void clear ()
 
KmeansClusteringInfo cluster_info (std::vector< Point > const &data) const
 
std::vector< size_t > cluster_sizes () const
 
KmeansInitializationStrategy initialization_strategy () const
 
Kmeansinitialization_strategy (KmeansInitializationStrategy value)
 
size_t max_iterations () const
 
Kmeansmax_iterations (size_t value)
 
Kmeansoperator= (Kmeans const &)=default
 
Kmeansoperator= (Kmeans &&)=default
 
size_t run (std::vector< Point > const &data, size_t const k)
 

Public Types

using value_type = Point
 

Public Attributes

std::function< void(void)> report_initialization
 
std::function< void(size_t i)> report_iteration
 

Protected Member Functions

virtual bool assign_to_centroids (std::vector< Point > const &data, std::vector< Point > const &centroids, std::vector< size_t > &assignments)
 
virtual KmeansClusteringInfo cluster_info (std::vector< Point > const &data, std::vector< size_t > const &assignments, std::vector< Point > const &centroids) const
 
virtual bool data_validation (std::vector< Point > const &data) const
 
virtual double distance (Point const &lhs, Point const &rhs) const =0
 
virtual std::pair< size_t, double > find_nearest_cluster (std::vector< Point > const &centroids, Point const &datum) const
 
virtual void initialize (std::vector< Point > const &data, size_t const k)
 
virtual bool lloyd_step (std::vector< Point > const &data, std::vector< size_t > &assignments, std::vector< Point > &centroids)
 
virtual void post_loop_hook (std::vector< Point > const &data, std::vector< size_t > &assignments, std::vector< Point > &centroids)
 
virtual void pre_loop_hook (std::vector< Point > const &data, std::vector< size_t > &assignments, std::vector< Point > &centroids)
 
virtual bool treat_empty_centroids (std::vector< Point > const &data, std::vector< size_t > &assignments, std::vector< Point > &centroids, std::unordered_set< size_t > const &empty_centroids)
 
virtual void update_centroids (std::vector< Point > const &data, std::vector< size_t > const &assignments, std::vector< Point > &centroids)=0
 

Constructor & Destructor Documentation

Kmeans ( )
default
virtual ~Kmeans ( )
virtualdefault
Kmeans ( Kmeans< Point > const &  )
default
Kmeans ( Kmeans< Point > &&  )
default

Member Function Documentation

virtual bool assign_to_centroids ( std::vector< Point > const &  data,
std::vector< Point > const &  centroids,
std::vector< size_t > &  assignments 
)
inlineprotectedvirtual

Definition at line 338 of file utils/math/kmeans.hpp.

std::vector<size_t> const& assignments ( ) const
inline

Definition at line 174 of file utils/math/kmeans.hpp.

Kmeans& assignments ( std::vector< size_t > const &  value)
inline

Definition at line 179 of file utils/math/kmeans.hpp.

std::vector<Point> const& centroids ( ) const
inline

Definition at line 185 of file utils/math/kmeans.hpp.

Kmeans& centroids ( std::vector< Point > const &  value)
inline

Definition at line 190 of file utils/math/kmeans.hpp.

void clear ( )
inline

Definition at line 209 of file utils/math/kmeans.hpp.

KmeansClusteringInfo cluster_info ( std::vector< Point > const &  data) const
inline

Definition at line 219 of file utils/math/kmeans.hpp.

virtual KmeansClusteringInfo cluster_info ( std::vector< Point > const &  data,
std::vector< size_t > const &  assignments,
std::vector< Point > const &  centroids 
) const
inlineprotectedvirtual

Definition at line 384 of file utils/math/kmeans.hpp.

std::vector<size_t> cluster_sizes ( ) const
inline

Definition at line 196 of file utils/math/kmeans.hpp.

virtual bool data_validation ( std::vector< Point > const &  data) const
inlineprotectedvirtual

Definition at line 308 of file utils/math/kmeans.hpp.

virtual double distance ( Point const &  lhs,
Point const &  rhs 
) const
protectedpure virtual
virtual std::pair<size_t, double> find_nearest_cluster ( std::vector< Point > const &  centroids,
Point const &  datum 
) const
inlineprotectedvirtual

Definition at line 365 of file utils/math/kmeans.hpp.

KmeansInitializationStrategy initialization_strategy ( ) const
inline

Definition at line 239 of file utils/math/kmeans.hpp.

Kmeans& initialization_strategy ( KmeansInitializationStrategy  value)
inline

Definition at line 244 of file utils/math/kmeans.hpp.

virtual void initialize ( std::vector< Point > const &  data,
size_t const  k 
)
inlineprotectedvirtual

Definition at line 263 of file utils/math/kmeans.hpp.

virtual bool lloyd_step ( std::vector< Point > const &  data,
std::vector< size_t > &  assignments,
std::vector< Point > &  centroids 
)
inlineprotectedvirtual

Definition at line 324 of file utils/math/kmeans.hpp.

size_t max_iterations ( ) const
inline

Definition at line 225 of file utils/math/kmeans.hpp.

Kmeans& max_iterations ( size_t  value)
inline

Definition at line 230 of file utils/math/kmeans.hpp.

Kmeans& operator= ( Kmeans< Point > const &  )
default
Kmeans& operator= ( Kmeans< Point > &&  )
default
virtual void post_loop_hook ( std::vector< Point > const &  data,
std::vector< size_t > &  assignments,
std::vector< Point > &  centroids 
)
inlineprotectedvirtual

Definition at line 518 of file utils/math/kmeans.hpp.

virtual void pre_loop_hook ( std::vector< Point > const &  data,
std::vector< size_t > &  assignments,
std::vector< Point > &  centroids 
)
inlineprotectedvirtual

Definition at line 314 of file utils/math/kmeans.hpp.

size_t run ( std::vector< Point > const &  data,
size_t const  k 
)
inline

Definition at line 118 of file utils/math/kmeans.hpp.

virtual bool treat_empty_centroids ( std::vector< Point > const &  data,
std::vector< size_t > &  assignments,
std::vector< Point > &  centroids,
std::unordered_set< size_t > const &  empty_centroids 
)
inlineprotectedvirtual

Definition at line 426 of file utils/math/kmeans.hpp.

virtual void update_centroids ( std::vector< Point > const &  data,
std::vector< size_t > const &  assignments,
std::vector< Point > &  centroids 
)
protectedpure virtual

Member Typedef Documentation

using value_type = Point

Definition at line 99 of file utils/math/kmeans.hpp.

Member Data Documentation

std::function<void( void )> report_initialization

Definition at line 254 of file utils/math/kmeans.hpp.

std::function<void( size_t i )> report_iteration

Definition at line 255 of file utils/math/kmeans.hpp.


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