kmeans
A C++ library for k-means
Loading...
Searching...
No Matches
kmeans::RefineLloyd< Index_, Data_, Cluster_, Float_, Matrix_ > Class Template Referencefinal

Implements the Lloyd algorithm for k-means clustering. More...

#include <RefineLloyd.hpp>

Inheritance diagram for kmeans::RefineLloyd< Index_, Data_, Cluster_, Float_, Matrix_ >:
Collaboration diagram for kmeans::RefineLloyd< Index_, Data_, Cluster_, Float_, Matrix_ >:

Public Member Functions

 RefineLloyd (RefineLloydOptions options)
 
 RefineLloyd ()=default
 
RefineLloydOptionsget_options ()
 
- Public Member Functions inherited from kmeans::Refine< Index_, Data_, Cluster_, Float_, Matrix_ >
virtual Details< Index_ > run (const Matrix_ &data, Cluster_ num_centers, Float_ *centers, Cluster_ *clusters) const =0
 

Detailed Description

template<typename Index_, typename Data_, typename Cluster_, typename Float_, typename Matrix_ = Matrix<Index_, Data_>>
class kmeans::RefineLloyd< Index_, Data_, Cluster_, Float_, Matrix_ >

Implements the Lloyd algorithm for k-means clustering.

The Lloyd algorithm is the simplest k-means clustering algorithm, involving several iterations of batch assignments and center calculations. Specifically, we assign each observation to its closest cluster, and once all points are assigned, we recompute the cluster centroids. This is repeated until there are no reassignments or the maximum number of iterations is reached.

In the Details::status returned by run(), the status code is either 0 (success) or 2 (maximum iterations reached without convergence). Previous versions of the library would report a status code of 1 upon encountering an empty cluster, but these are now just ignored.

Template Parameters
Index_Integer type for the observation indices.
Data_Numeric type for the data.
Cluster_Integer type for the cluster assignments.
Float_Floating-point type for the centroids. This will also be used for any internal distance calculations.
Matrix_Type for the input data matrix. This should satisfy the Matrix interface.
See also
Lloyd, S. P. (1982).
Least squares quantization in PCM. IEEE Transactions on Information Theory 28, 128-137.

Constructor & Destructor Documentation

◆ RefineLloyd() [1/2]

template<typename Index_ , typename Data_ , typename Cluster_ , typename Float_ , typename Matrix_ = Matrix<Index_, Data_>>
kmeans::RefineLloyd< Index_, Data_, Cluster_, Float_, Matrix_ >::RefineLloyd ( RefineLloydOptions options)
inline
Parameters
optionsFurther options to the Lloyd algorithm.

◆ RefineLloyd() [2/2]

template<typename Index_ , typename Data_ , typename Cluster_ , typename Float_ , typename Matrix_ = Matrix<Index_, Data_>>
kmeans::RefineLloyd< Index_, Data_, Cluster_, Float_, Matrix_ >::RefineLloyd ( )
default

Default constructor.

Member Function Documentation

◆ get_options()

template<typename Index_ , typename Data_ , typename Cluster_ , typename Float_ , typename Matrix_ = Matrix<Index_, Data_>>
RefineLloydOptions & kmeans::RefineLloyd< Index_, Data_, Cluster_, Float_, Matrix_ >::get_options ( )
inline
Returns
Options for Lloyd clustering, to be modified prior to calling run().

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