mlpack  3.4.2
example_tree.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_TREE_EXAMPLE_TREE_HPP
15 #define MLPACK_CORE_TREE_EXAMPLE_TREE_HPP
16 
17 namespace mlpack {
18 namespace tree {
19 
53 template<typename MetricType = metric::LMetric<2, true>,
54  typename StatisticType = EmptyStatistic,
55  typename MatType = arma::mat>
57 {
58  public:
79  ExampleTree(const MatType& dataset,
80  MetricType& metric);
81 
83  size_t NumChildren() const;
84 
86  const ExampleTree& Child(const size_t i) const;
88  ExampleTree& Child(const size_t i);
89 
91  ExampleTree* Parent() const;
92 
94  size_t NumPoints() const;
95 
106  size_t Point(const size_t i) const;
107 
115  size_t NumDescendants() const;
116 
123  size_t Descendant(const size_t i) const;
124 
126  const StatisticType& Stat() const;
128  StatisticType& Stat();
129 
131  const MetricType& Metric() const;
133  MetricType& Metric();
134 
143  double MinDistance(const MatType& point) const;
144 
153  double MinDistance(const ExampleTree& other) const;
154 
163  double MaxDistance(const MatType& point) const;
164 
173  double MaxDistance(const ExampleTree& other) const;
174 
186  math::Range RangeDistance(const MatType& point) const;
187 
199  math::Range RangeDistance(const ExampleTree& other) const;
200 
206  void Centroid(arma::vec& centroid) const;
207 
215 
220  double ParentDistance() const;
221 
222  private:
225  StatisticType stat;
226 
234  MetricType& metric;
235 };
236 
237 } // namespace tree
238 } // namespace mlpack
239 
240 #endif
mlpack::tree::ExampleTree::RangeDistance
math::Range RangeDistance(const ExampleTree &other) const
Return both the minimum and maximum distances between this node and another node as a math::Range obj...
mlpack::tree::ExampleTree::MaxDistance
double MaxDistance(const MatType &point) const
Return the maximum distance between this node and a point.
mlpack::tree::ExampleTree::Centroid
void Centroid(arma::vec &centroid) const
Fill the given vector with the center of the node.
mlpack::tree::ExampleTree::Descendant
size_t Descendant(const size_t i) const
Get the index of a particular descendant point.
mlpack::tree::ExampleTree::NumDescendants
size_t NumDescendants() const
Get the number of descendant points.
mlpack::tree::ExampleTree::ExampleTree
ExampleTree(const MatType &dataset, MetricType &metric)
This constructor will build the tree given a dataset and an instantiated metric.
mlpack::tree::ExampleTree::MaxDistance
double MaxDistance(const ExampleTree &other) const
Return the maximum distance between this node and another node.
mlpack::tree::ExampleTree::RangeDistance
math::Range RangeDistance(const MatType &point) const
Return both the minimum and maximum distances between this node and a point as a math::Range object.
mlpack::tree::ExampleTree::FurthestDescendantDistance
double FurthestDescendantDistance() const
Get the distance from the center of the node to the furthest descendant point of this node.
mlpack::tree::ExampleTree::Point
size_t Point(const size_t i) const
Return the index of a particular point of this node.
mlpack::tree::ExampleTree::Metric
MetricType & Metric()
Modify the instantiated metric for this node.
mlpack::tree::ExampleTree::NumPoints
size_t NumPoints() const
Return the number of points held in this node.
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_cli11.hpp:21
mlpack::tree::ExampleTree::Parent
ExampleTree * Parent() const
Return the parent node (NULL if this is the root of the tree).
mlpack::tree::ExampleTree::NumChildren
size_t NumChildren() const
Return the number of children of this node.
mlpack::tree::ExampleTree::MinDistance
double MinDistance(const MatType &point) const
Return the minimum distance between this node and a point.
mlpack::tree::ExampleTree::MinDistance
double MinDistance(const ExampleTree &other) const
Return the minimum distance between this node and another node.
mlpack::math::RangeType< double >
mlpack::tree::ExampleTree::Child
const ExampleTree & Child(const size_t i) const
Return a particular child of this node.
mlpack::tree::ExampleTree
This is not an actual space tree but instead an example tree that exists to show and document all the...
Definition: example_tree.hpp:57
mlpack::tree::ExampleTree::Metric
const MetricType & Metric() const
Get the instantiated metric for this node.
mlpack::tree::ExampleTree::Child
ExampleTree & Child(const size_t i)
Modify a particular child of this node.
mlpack::tree::ExampleTree::Stat
const StatisticType & Stat() const
Get the statistic for this node.
mlpack::tree::ExampleTree::ParentDistance
double ParentDistance() const
Get the distance from the center of this node to the center of the parent node.
mlpack::tree::ExampleTree::Stat
StatisticType & Stat()
Modify the statistic for this node.