NaiveKMeans< MetricType, MatType > Class Template Reference

This is an implementation of a single iteration of Lloyd's algorithm for k-means. More...

Public Member Functions

 NaiveKMeans (const MatType &dataset, MetricType &metric)
 Construct the NaiveKMeans object with the given dataset and metric. More...

 
size_t DistanceCalculations () const
 
double Iterate (const arma::mat &centroids, arma::mat &newCentroids, arma::Col< size_t > &counts)
 Run a single iteration of the Lloyd algorithm, updating the given centroids into the newCentroids matrix. More...

 

Detailed Description


template
<
typename
MetricType
,
typename
MatType
>

class mlpack::kmeans::NaiveKMeans< MetricType, MatType >

This is an implementation of a single iteration of Lloyd's algorithm for k-means.

If your intention is to run the full k-means algorithm, you are looking for the mlpack::kmeans::KMeans class instead of this one. This class is used by KMeans as the actual implementation of the Lloyd iteration.

Parameters
MetricTypeType of metric used with this implementation.
MatTypeMatrix type (arma::mat or arma::sp_mat).

Definition at line 32 of file naive_kmeans.hpp.

Constructor & Destructor Documentation

◆ NaiveKMeans()

NaiveKMeans ( const MatType &  dataset,
MetricType &  metric 
)

Construct the NaiveKMeans object with the given dataset and metric.

Parameters
datasetDataset.
metricInstantiated metric.

Member Function Documentation

◆ DistanceCalculations()

size_t DistanceCalculations ( ) const
inline

Definition at line 57 of file naive_kmeans.hpp.

◆ Iterate()

double Iterate ( const arma::mat &  centroids,
arma::mat &  newCentroids,
arma::Col< size_t > &  counts 
)

Run a single iteration of the Lloyd algorithm, updating the given centroids into the newCentroids matrix.

If any cluster is empty (that is, if any cluster has no points assigned to it), then the centroid associated with that cluster may be filled with invalid data (it will be corrected later).

Parameters
centroidsCurrent cluster centroids.
newCentroidsNew cluster centroids.
countsNumber of points in each cluster at the end of the iteration.

The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/methods/kmeans/naive_kmeans.hpp