dual_tree_kmeans_rules.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_KMEANS_DUAL_TREE_KMEANS_RULES_HPP
15 #define MLPACK_METHODS_KMEANS_DUAL_TREE_KMEANS_RULES_HPP
16 
18 
19 namespace mlpack {
20 namespace kmeans {
21 
22 template<typename MetricType, typename TreeType>
24 {
25  public:
26  DualTreeKMeansRules(const arma::mat& centroids,
27  const arma::mat& dataset,
28  arma::Row<size_t>& assignments,
29  arma::vec& upperBounds,
30  arma::vec& lowerBounds,
31  MetricType& metric,
32  const std::vector<bool>& prunedPoints,
33  const std::vector<size_t>& oldFromNewCentroids,
34  std::vector<bool>& visited);
35 
36  double BaseCase(const size_t queryIndex, const size_t referenceIndex);
37 
38  double Score(const size_t queryIndex, TreeType& referenceNode);
39  double Score(TreeType& queryNode, TreeType& referenceNode);
40  double Rescore(const size_t queryIndex,
41  TreeType& referenceNode,
42  const double oldScore);
43  double Rescore(TreeType& queryNode,
44  TreeType& referenceNode,
45  const double oldScore);
46 
48 
49  TraversalInfoType& TraversalInfo() { return traversalInfo; }
50  const TraversalInfoType& TraversalInfo() const { return traversalInfo; }
51 
52  size_t BaseCases() const { return baseCases; }
53  size_t& BaseCases() { return baseCases; }
54 
55  size_t Scores() const { return scores; }
56  size_t& Scores() { return scores; }
57 
60  size_t MinimumBaseCases() const { return 0; }
61 
62  private:
63  const arma::mat& centroids;
64  const arma::mat& dataset;
65  arma::Row<size_t>& assignments;
66  arma::vec& upperBounds;
67  arma::vec& lowerBounds;
68  MetricType& metric;
69 
70  const std::vector<bool>& prunedPoints;
71 
72  const std::vector<size_t>& oldFromNewCentroids;
73 
74  std::vector<bool>& visited;
75 
76  size_t baseCases;
77  size_t scores;
78 
79  TraversalInfoType traversalInfo;
80 
81  size_t lastQueryIndex;
82  size_t lastReferenceIndex;
83  size_t lastBaseCase;
84 };
85 
86 } // namespace kmeans
87 } // namespace mlpack
88 
89 #include "dual_tree_kmeans_rules_impl.hpp"
90 
91 #endif
The TraversalInfo class holds traversal information which is used in dual-tree (and single-tree) trav...
Linear algebra utility functions, generally performed on matrices or vectors.
const TraversalInfoType & TraversalInfo() const
double Score(const size_t queryIndex, TreeType &referenceNode)
DualTreeKMeansRules(const arma::mat &centroids, const arma::mat &dataset, arma::Row< size_t > &assignments, arma::vec &upperBounds, arma::vec &lowerBounds, MetricType &metric, const std::vector< bool > &prunedPoints, const std::vector< size_t > &oldFromNewCentroids, std::vector< bool > &visited)
size_t MinimumBaseCases() const
Get the minimum number of base cases needed for correct results for each query point.
double Rescore(const size_t queryIndex, TreeType &referenceNode, const double oldScore)
double BaseCase(const size_t queryIndex, const size_t referenceIndex)
tree::TraversalInfo< TreeType > TraversalInfoType