pelleg_moore_kmeans_rules.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_KMEANS_PELLEG_MOORE_KMEANS_RULES_HPP
15 #define MLPACK_METHODS_KMEANS_PELLEG_MOORE_KMEANS_RULES_HPP
16 
17 namespace mlpack {
18 namespace kmeans {
19 
32 template<typename MetricType, typename TreeType>
34 {
35  public:
46  PellegMooreKMeansRules(const typename TreeType::Mat& dataset,
47  const arma::mat& centroids,
48  arma::mat& newCentroids,
49  arma::Col<size_t>& counts,
50  MetricType& metric);
51 
59  double BaseCase(const size_t queryIndex, const size_t referenceIndex);
60 
69  double Score(const size_t queryIndex, TreeType& referenceNode);
70 
79  double Rescore(const size_t queryIndex,
80  TreeType& referenceNode,
81  const double oldScore);
82 
84  size_t DistanceCalculations() const { return distanceCalculations; }
86  size_t& DistanceCalculations() { return distanceCalculations; }
87 
88  private:
90  const typename TreeType::Mat& dataset;
92  const arma::mat& centroids;
94  arma::mat& newCentroids;
96  arma::Col<size_t>& counts;
98  MetricType& metric;
99 
101  size_t distanceCalculations;
102 };
103 
104 } // namespace kmeans
105 } // namespace mlpack
106 
107 // Include implementation.
108 #include "pelleg_moore_kmeans_rules_impl.hpp"
109 
110 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
size_t DistanceCalculations() const
Get the number of distance calculations that have been performed.
double BaseCase(const size_t queryIndex, const size_t referenceIndex)
The BaseCase() function for this single-tree algorithm does nothing.
double Score(const size_t queryIndex, TreeType &referenceNode)
Determine if a cluster can be pruned, and if not, perform point-to-cluster comparisons.
size_t & DistanceCalculations()
Modify the number of distance calculations that have been performed.
PellegMooreKMeansRules(const typename TreeType::Mat &dataset, const arma::mat &centroids, arma::mat &newCentroids, arma::Col< size_t > &counts, MetricType &metric)
Create the PellegMooreKMeansRules object.
double Rescore(const size_t queryIndex, TreeType &referenceNode, const double oldScore)
Rescore to determine if a node can be pruned.
The rules class for the single-tree Pelleg-Moore kd-tree traversal for k-means clustering.