midpoint_split.hpp
Go to the documentation of this file.
1 
15 #ifndef MLPACK_CORE_TREE_BINARY_SPACE_TREE_MIDPOINT_SPLIT_HPP
16 #define MLPACK_CORE_TREE_BINARY_SPACE_TREE_MIDPOINT_SPLIT_HPP
17 
18 #include <mlpack/prereqs.hpp>
20 
21 namespace mlpack {
22 namespace tree {
23 
29 template<typename BoundType, typename MatType = arma::mat>
31 {
32  public:
34  struct SplitInfo
35  {
39  double splitVal;
40  };
54  static bool SplitNode(const BoundType& bound,
55  MatType& data,
56  const size_t begin,
57  const size_t count,
58  SplitInfo& splitInfo);
59 
72  static size_t PerformSplit(MatType& data,
73  const size_t begin,
74  const size_t count,
75  const SplitInfo& splitInfo)
76  {
77  return split::PerformSplit<MatType, MidpointSplit>(data, begin, count,
78  splitInfo);
79  }
80 
96  static size_t PerformSplit(MatType& data,
97  const size_t begin,
98  const size_t count,
99  const SplitInfo& splitInfo,
100  std::vector<size_t>& oldFromNew)
101  {
102  return split::PerformSplit<MatType, MidpointSplit>(data, begin, count,
103  splitInfo, oldFromNew);
104  }
105 
112  template<typename VecType>
113  static bool AssignToLeftNode(const VecType& point,
114  const SplitInfo& splitInfo)
115  {
116  return point[splitInfo.splitDimension] < splitInfo.splitVal;
117  }
118 };
119 
120 } // namespace tree
121 } // namespace mlpack
122 
123 // Include implementation.
124 #include "midpoint_split_impl.hpp"
125 
126 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
double splitVal
The split in dimension splitDimension is based on this value.
static bool SplitNode(const BoundType &bound, MatType &data, const size_t begin, const size_t count, SplitInfo &splitInfo)
Find the partition of the node.
The core includes that mlpack expects; standard C++ includes and Armadillo.
A binary space partitioning tree node is split into its left and right child.
static size_t PerformSplit(MatType &data, const size_t begin, const size_t count, const SplitInfo &splitInfo)
Perform the split process according to the information about the split.
A struct that contains an information about the split.
static bool AssignToLeftNode(const VecType &point, const SplitInfo &splitInfo)
Indicates that a point should be assigned to the left subtree.
size_t splitDimension
The dimension to split the node on.
static size_t PerformSplit(MatType &data, const size_t begin, const size_t count, const SplitInfo &splitInfo, std::vector< size_t > &oldFromNew)
Perform the split process according to the information about the split and return the list of changed...