mlpack  2.0.1
pelleg_moore_kmeans_rules.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_METHODS_KMEANS_PELLEG_MOORE_KMEANS_RULES_HPP
17 #define __MLPACK_METHODS_KMEANS_PELLEG_MOORE_KMEANS_RULES_HPP
18 
20 
21 namespace mlpack {
22 namespace kmeans {
23 
36 template<typename MetricType, typename TreeType>
38 {
39  public:
50  PellegMooreKMeansRules(const typename TreeType::Mat& dataset,
51  const arma::mat& centroids,
52  arma::mat& newCentroids,
53  arma::Col<size_t>& counts,
54  MetricType& metric);
55 
63  double BaseCase(const size_t queryIndex, const size_t referenceIndex);
64 
73  double Score(const size_t queryIndex, TreeType& referenceNode);
74 
83  double Rescore(const size_t queryIndex,
84  TreeType& referenceNode,
85  const double oldScore);
86 
88  size_t DistanceCalculations() const { return distanceCalculations; }
91 
92  private:
94  const typename TreeType::Mat& dataset;
96  const arma::mat& centroids;
98  arma::mat& newCentroids;
100  arma::Col<size_t>& counts;
102  MetricType& metric;
103 
106 };
107 
108 } // namespace kmeans
109 } // namespace mlpack
110 
111 // Include implementation.
112 #include "pelleg_moore_kmeans_rules_impl.hpp"
113 
114 #endif
const TreeType::Mat & dataset
The dataset.
Linear algebra utility functions, generally performed on matrices or vectors.
double Rescore(const size_t queryIndex, TreeType &referenceNode, const double oldScore)
Rescore to determine if a node can be pruned.
size_t DistanceCalculations() const
Get the number of distance calculations that have been performed.
arma::Col< size_t > & counts
The counts of points in each cluster.
double BaseCase(const size_t queryIndex, const size_t referenceIndex)
The BaseCase() function for this single-tree algorithm does nothing.
size_t distanceCalculations
The number of O(d) 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 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.
The rules class for the single-tree Pelleg-Moore kd-tree traversal for k-means clustering.