mlpack 3.4.2
pelleg_moore_kmeans.hpp
Go to the documentation of this file.
1
13#ifndef MLPACK_METHODS_KMEANS_PELLEG_MOORE_KMEANS_HPP
14#define MLPACK_METHODS_KMEANS_PELLEG_MOORE_KMEANS_HPP
15
18
19namespace mlpack {
20namespace kmeans {
21
41template<typename MetricType, typename MatType>
43{
44 public:
48 PellegMooreKMeans(const MatType& dataset, MetricType& metric);
49
54
63 double Iterate(const arma::mat& centroids,
64 arma::mat& newCentroids,
65 arma::Col<size_t>& counts);
66
68 size_t DistanceCalculations() const { return distanceCalculations; }
70 size_t& DistanceCalculations() { return distanceCalculations; }
71
75
76 private:
78 const MatType& datasetOrig; // Maybe not necessary.
80 TreeType* tree;
82 const MatType& dataset;
84 MetricType& metric;
85
87 size_t distanceCalculations;
88};
89
90} // namespace kmeans
91} // namespace mlpack
92
93#include "pelleg_moore_kmeans_impl.hpp"
94
95#endif
An implementation of Pelleg-Moore's 'blacklist' algorithm for k-means clustering.
double Iterate(const arma::mat &centroids, arma::mat &newCentroids, arma::Col< size_t > &counts)
Run a single iteration of the Pelleg-Moore blacklist algorithm, updating the given centroids into the...
PellegMooreKMeans(const MatType &dataset, MetricType &metric)
Construct the PellegMooreKMeans object, which must construct a tree.
size_t DistanceCalculations() const
Return the number of distance calculations.
tree::KDTree< MetricType, PellegMooreKMeansStatistic, MatType > TreeType
Convenience typedef for the tree.
size_t & DistanceCalculations()
Modify the number of distance calculations.
~PellegMooreKMeans()
Delete the tree constructed by the PellegMooreKMeans object.
A binary space partitioning tree, such as a KD-tree or a ball tree.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1