mlpack  2.0.1
hamerly_kmeans.hpp
Go to the documentation of this file.
1 
14 #ifndef __MLPACK_METHODS_KMEANS_HAMERLY_KMEANS_HPP
15 #define __MLPACK_METHODS_KMEANS_HAMERLY_KMEANS_HPP
16 
17 namespace mlpack {
18 namespace kmeans {
19 
20 template<typename MetricType, typename MatType>
22 {
23  public:
28  HamerlyKMeans(const MatType& dataset, MetricType& metric);
29 
38  double Iterate(const arma::mat& centroids,
39  arma::mat& newCentroids,
40  arma::Col<size_t>& counts);
41 
42  size_t DistanceCalculations() const { return distanceCalculations; }
43 
44  private:
46  const MatType& dataset;
48  MetricType& metric;
49 
52 
54  arma::vec upperBounds;
56  arma::vec lowerBounds;
58  arma::Col<size_t> assignments;
59 
62 };
63 
64 } // namespace kmeans
65 } // namespace mlpack
66 
67 // Include implementation.
68 #include "hamerly_kmeans_impl.hpp"
69 
70 #endif
const MatType & dataset
The dataset.
arma::vec minClusterDistances
Minimum cluster distances from each cluster.
size_t DistanceCalculations() const
Linear algebra utility functions, generally performed on matrices or vectors.
size_t distanceCalculations
Track distance calculations.
arma::vec upperBounds
Upper bounds for each point.
MetricType & metric
The instantiated metric.
HamerlyKMeans(const MatType &dataset, MetricType &metric)
Construct the HamerlyKMeans object, which must store several sets of bounds.
arma::Col< size_t > assignments
Assignments for each point.
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...
arma::vec lowerBounds
Lower bounds for each point.