mlpack
Public Types | Public Member Functions | List of all members
mlpack::kmeans::DualTreeKMeans< MetricType, MatType, TreeType > Class Template Reference

An algorithm for an exact Lloyd iteration which simply uses dual-tree nearest-neighbor search to find the nearest centroid for each point in the dataset. More...

#include <dual_tree_kmeans.hpp>

Public Types

typedef TreeType< MetricType, DualTreeKMeansStatistic, MatType > Tree
 Convenience typedef.
 
template<typename TreeMetricType , typename IgnoredStatType , typename TreeMatType >
using NNSTreeType = TreeType< TreeMetricType, DualTreeKMeansStatistic, TreeMatType >
 

Public Member Functions

 DualTreeKMeans (const MatType &dataset, MetricType &metric)
 Construct the DualTreeKMeans object, which will construct a tree on the points.
 
 ~DualTreeKMeans ()
 Delete the tree constructed by the DualTreeKMeans object.
 
double Iterate (const arma::mat &centroids, arma::mat &newCentroids, arma::Col< size_t > &counts)
 Run a single iteration of the dual-tree nearest neighbor algorithm for k-means, updating the given centroids into the newCentroids matrix. More...
 
size_t DistanceCalculations () const
 Return the number of distance calculations.
 
size_t & DistanceCalculations ()
 Modify the number of distance calculations.
 

Detailed Description

template<typename MetricType, typename MatType, template< typename TreeMetricType, typename TreeStatType, typename TreeMatType > class TreeType = tree::KDTree>
class mlpack::kmeans::DualTreeKMeans< MetricType, MatType, TreeType >

An algorithm for an exact Lloyd iteration which simply uses dual-tree nearest-neighbor search to find the nearest centroid for each point in the dataset.

The conditions under which this will perform best are probably limited to the case where k is close to the number of points in the dataset, and the number of iterations of the k-means algorithm will be few.

Member Function Documentation

◆ Iterate()

template<typename MetricType , typename MatType , template< typename TreeMetricType, typename TreeStatType, typename TreeMatType > class TreeType>
double mlpack::kmeans::DualTreeKMeans< MetricType, MatType, TreeType >::Iterate ( const arma::mat &  centroids,
arma::mat &  newCentroids,
arma::Col< size_t > &  counts 
)

Run a single iteration of the dual-tree nearest neighbor algorithm for k-means, updating the given centroids into the newCentroids matrix.

Parameters
centroidsCurrent cluster centroids.
newCentroidsNew cluster centroids.
countsCurrent counts, to be overwritten with new counts.

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