mlpack 3.4.2
hamerly_kmeans.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_METHODS_KMEANS_HAMERLY_KMEANS_HPP
13#define MLPACK_METHODS_KMEANS_HAMERLY_KMEANS_HPP
14
15namespace mlpack {
16namespace kmeans {
17
18template<typename MetricType, typename MatType>
20{
21 public:
26 HamerlyKMeans(const MatType& dataset, MetricType& metric);
27
36 double Iterate(const arma::mat& centroids,
37 arma::mat& newCentroids,
38 arma::Col<size_t>& counts);
39
40 size_t DistanceCalculations() const { return distanceCalculations; }
41
42 private:
44 const MatType& dataset;
46 MetricType& metric;
47
49 arma::vec minClusterDistances;
50
52 arma::vec upperBounds;
54 arma::vec lowerBounds;
56 arma::Col<size_t> assignments;
57
59 size_t distanceCalculations;
60};
61
62} // namespace kmeans
63} // namespace mlpack
64
65// Include implementation.
66#include "hamerly_kmeans_impl.hpp"
67
68#endif
double Iterate(const arma::mat &centroids, arma::mat &newCentroids, arma::Col< size_t > &counts)
Run a single iteration of Hamerly's algorithm, updating the given centroids into the newCentroids mat...
HamerlyKMeans(const MatType &dataset, MetricType &metric)
Construct the HamerlyKMeans object, which must store several sets of bounds.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1