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 
15 namespace mlpack {
16 namespace kmeans {
17 
18 template<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
Linear algebra utility functions, generally performed on matrices or vectors.
double Iterate(const arma::mat &centroids, arma::mat &newCentroids, arma::Col< size_t > &counts)
Run a single iteration of Elkan&#39;s algorithm, updating the given centroids into the newCentroids matri...
size_t DistanceCalculations() const
ElkanKMeans(const MatType &dataset, MetricType &metric)
Construct the ElkanKMeans object, which must store several sets of bounds.