mlpack 3.4.2
elkan_kmeans.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_METHODS_KMEANS_ELKAN_KMEANS_HPP
13#define MLPACK_METHODS_KMEANS_ELKAN_KMEANS_HPP
14
15namespace mlpack {
16namespace kmeans {
17
18template<typename MetricType, typename MatType>
20{
21 public:
25 ElkanKMeans(const MatType& dataset, MetricType& metric);
26
35 double Iterate(const arma::mat& centroids,
36 arma::mat& newCentroids,
37 arma::Col<size_t>& counts);
38
39 size_t DistanceCalculations() const { return distanceCalculations; }
40
41 private:
43 const MatType& dataset;
45 MetricType& metric;
46
48 arma::mat clusterDistances;
50 arma::vec minClusterDistances;
51
53 arma::Col<size_t> assignments;
54
56 arma::vec upperBounds;
58 arma::mat lowerBounds;
59
61 size_t distanceCalculations;
62};
63
64} // namespace kmeans
65} // namespace mlpack
66
67// Include implementation.
68#include "elkan_kmeans_impl.hpp"
69
70#endif
ElkanKMeans(const MatType &dataset, MetricType &metric)
Construct the ElkanKMeans object, which must store several sets of bounds.
double Iterate(const arma::mat &centroids, arma::mat &newCentroids, arma::Col< size_t > &counts)
Run a single iteration of Elkan's algorithm, updating the given centroids into the newCentroids matri...
size_t DistanceCalculations() const
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1