mean_split.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_TREE_BINARY_SPACE_TREE_MEAN_SPLIT_HPP
15 #define MLPACK_CORE_TREE_BINARY_SPACE_TREE_MEAN_SPLIT_HPP
16 
17 #include <mlpack/prereqs.hpp>
19 
20 namespace mlpack {
21 namespace tree {
22 
28 template<typename BoundType, typename MatType = arma::mat>
29 class MeanSplit
30 {
31  public:
33  struct SplitInfo
34  {
38  double splitVal;
39  };
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 
73  static size_t PerformSplit(MatType& data,
74  const size_t begin,
75  const size_t count,
76  const SplitInfo& splitInfo)
77  {
78  return split::PerformSplit<MatType, MeanSplit>(data, begin, count,
79  splitInfo);
80  }
81 
98  static size_t PerformSplit(MatType& data,
99  const size_t begin,
100  const size_t count,
101  const SplitInfo& splitInfo,
102  std::vector<size_t>& oldFromNew)
103  {
104  return split::PerformSplit<MatType, MeanSplit>(data, begin, count,
105  splitInfo, oldFromNew);
106  }
107 
114  template<typename VecType>
115  static bool AssignToLeftNode(const VecType& point,
116  const SplitInfo& splitInfo)
117  {
118  return point[splitInfo.splitDimension] < splitInfo.splitVal;
119  }
120 };
121 
122 } // namespace tree
123 } // namespace mlpack
124 
125 // Include implementation.
126 #include "mean_split_impl.hpp"
127 
128 #endif
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
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.
Definition: mean_split.hpp:73
static bool SplitNode(const BoundType &bound, MatType &data, const size_t begin, const size_t count, SplitInfo &splitInfo)
Find the partition of the node.
An information about the partition.
Definition: mean_split.hpp:33
double splitVal
The split in dimension splitDimension is based on this value.
Definition: mean_split.hpp:38
A binary space partitioning tree node is split into its left and right child.
Definition: mean_split.hpp:29
static bool AssignToLeftNode(const VecType &point, const SplitInfo &splitInfo)
Indicates that a point should be assigned to the left subtree.
Definition: mean_split.hpp:115
size_t splitDimension
The dimension to split the node on.
Definition: mean_split.hpp:36
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...
Definition: mean_split.hpp:98