kmeans
k-means clustering in C++
Loading...
Searching...
No Matches
kmeans::Initialize< Index_, Data_, Cluster_, Float_, Matrix_ > Class Template Referenceabstract

Interface for k-means initialization algorithms. More...

#include <Initialize.hpp>

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

Public Member Functions

virtual Cluster_ run (const Matrix_ &data, Cluster_ num_centers, Float_ *centers) const =0
 

Detailed Description

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

Interface for k-means initialization algorithms.

Template Parameters
Index_Integer type of the observation indices. This should be the same as the index type of Matrix_.
Data_Numeric type of the input dataset. This should be the same as the data type of Matrix_.
Cluster_Integer type of the cluster assignments.
Float_Floating-point type of the centroids.
Matrix_Class satisfying the Matrix interface.

Member Function Documentation

◆ run()

template<typename Index_ , typename Data_ , typename Cluster_ , typename Float_ , class Matrix_ = Matrix<Index_, Data_>>
virtual Cluster_ kmeans::Initialize< Index_, Data_, Cluster_, Float_, Matrix_ >::run ( const Matrix_ & data,
Cluster_ num_centers,
Float_ * centers ) const
pure virtual
Parameters
dataA matrix containing data for each observation.
num_centersNumber of cluster centers.
[out]centersPointer to an array of length equal to the product of num_centers and data.num_dimensions(). This contains a column-major matrix where rows correspond to dimensions and columns correspond to cluster centers. On output, each column will contain the final centroid locations for each cluster.
Returns
centers is filled with the new cluster centers and the number of filled centers is returned. The latter is usually equal to num_centers, but may not be if, e.g., num_centers is greater than the number of observations. If the returned value is less than num_centers, only the left-most columns in centers will be filled.

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