mlpack  2.0.1
elkan_kmeans.hpp
Go to the documentation of this file.
1 
14 #ifndef __MLPACK_METHODS_KMEANS_ELKAN_KMEANS_HPP
15 #define __MLPACK_METHODS_KMEANS_ELKAN_KMEANS_HPP
16 
17 namespace mlpack {
18 namespace kmeans {
19 
20 template<typename MetricType, typename MatType>
22 {
23  public:
27  ElkanKMeans(const MatType& dataset, MetricType& metric);
28 
37  double Iterate(const arma::mat& centroids,
38  arma::mat& newCentroids,
39  arma::Col<size_t>& counts);
40 
41  size_t DistanceCalculations() const { return distanceCalculations; }
42 
43  private:
45  const MatType& dataset;
47  MetricType& metric;
48 
50  arma::mat clusterDistances;
53 
55  arma::Col<size_t> assignments;
56 
58  arma::vec upperBounds;
60  arma::mat lowerBounds;
61 
64 };
65 
66 } // namespace kmeans
67 } // namespace mlpack
68 
69 // Include implementation.
70 #include "elkan_kmeans_impl.hpp"
71 
72 #endif
ElkanKMeans(const MatType &dataset, MetricType &metric)
Construct the ElkanKMeans object, which must store several sets of bounds.
size_t DistanceCalculations() const
Linear algebra utility functions, generally performed on matrices or vectors.
arma::vec upperBounds
Upper bounds on the distance between each point and its closest cluster.
arma::vec minClusterDistances
Half the distance from a cluster to its nearest cluster (s(c)).
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
Track distance calculations.
MetricType & metric
The instantiated metric.
arma::mat lowerBounds
Lower bounds on the distance between each point and each cluster.
arma::Col< size_t > assignments
Holds the index of the cluster that owns each point.
arma::mat clusterDistances
Holds intra-cluster distances.
const MatType & dataset
The dataset.