mlpack 3.4.2
rp_tree_max_split.hpp
Go to the documentation of this file.
1
13#ifndef MLPACK_CORE_TREE_BINARY_SPACE_TREE_RP_TREE_MAX_SPLIT_HPP
14#define MLPACK_CORE_TREE_BINARY_SPACE_TREE_RP_TREE_MAX_SPLIT_HPP
15
16#include <mlpack/prereqs.hpp>
18
19namespace mlpack {
20namespace tree {
21
31template<typename BoundType, typename MatType = arma::mat>
33{
34 public:
36 typedef typename MatType::elem_type ElemType;
38 struct SplitInfo
39 {
41 arma::Col<ElemType> direction;
44 };
45
57 static bool SplitNode(const BoundType& /*bound*/,
58 MatType& data,
59 const size_t begin,
60 const size_t count,
61 SplitInfo& splitInfo);
62
75 static size_t PerformSplit(MatType& data,
76 const size_t begin,
77 const size_t count,
78 const SplitInfo& splitInfo)
79 {
80 return split::PerformSplit<MatType, RPTreeMaxSplit>(data, begin, count,
81 splitInfo);
82 }
83
99 static size_t PerformSplit(MatType& data,
100 const size_t begin,
101 const size_t count,
102 const SplitInfo& splitInfo,
103 std::vector<size_t>& oldFromNew)
104 {
105 return split::PerformSplit<MatType, RPTreeMaxSplit>(data, begin, count,
106 splitInfo, oldFromNew);
107 }
108
115 template<typename VecType>
116 static bool AssignToLeftNode(const VecType& point, const SplitInfo& splitInfo)
117 {
118 return (arma::dot(point, splitInfo.direction) <= splitInfo.splitVal);
119 }
120
121 private:
133 static bool GetSplitVal(const MatType& data,
134 const size_t begin,
135 const size_t count,
136 const arma::Col<ElemType>& direction,
137 ElemType& splitVal);
138};
139
140} // namespace tree
141} // namespace mlpack
142
143// Include implementation.
144#include "rp_tree_max_split_impl.hpp"
145
146#endif // MLPACK_CORE_TREE_BINARY_SPACE_TREE_RP_TREE_MAX_SPLIT_HPP
This class splits a node by a random hyperplane.
MatType::elem_type ElemType
The element type held by the matrix type.
static bool SplitNode(const BoundType &, MatType &data, const size_t begin, const size_t count, SplitInfo &splitInfo)
Split the node by a random hyperplane.
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.
static bool AssignToLeftNode(const VecType &point, const SplitInfo &splitInfo)
Indicates that a point should be assigned to the left subtree.
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...
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
An information about the partition.
ElemType splitVal
The value according to which the node is being split.
arma::Col< ElemType > direction
The normal vector to the hyperplane that splits the node.