13 #ifndef MLPACK_CORE_TREE_BINARY_SPACE_TREE_RP_TREE_MAX_SPLIT_IMPL_HPP 14 #define MLPACK_CORE_TREE_BINARY_SPACE_TREE_RP_TREE_MAX_SPLIT_IMPL_HPP 22 template<
typename BoundType,
typename MatType>
35 return GetSplitVal(data, begin, count, splitInfo.
direction,
39 template<
typename BoundType,
typename MatType>
44 const arma::Col<ElemType>& direction,
47 const size_t maxNumSamples = 100;
48 const size_t numSamples = std::min(maxNumSamples, count);
54 arma::Col<ElemType> values(samples.n_elem);
57 for (
size_t k = 0; k < samples.n_elem; ++k)
58 values[k] = arma::dot(data.col(samples[k]), direction);
60 const ElemType maximum = arma::max(values);
61 const ElemType minimum = arma::min(values);
62 if (minimum == maximum)
65 splitVal = arma::median(values);
76 (maximum - splitVal) * 0.75);
78 if (splitVal == maximum)
87 #endif // MLPACK_CORE_TREE_BINARY_SPACE_TREE_RP_TREE_MAX_SPLIT_IMPL_HPP void ObtainDistinctSamples(const size_t loInclusive, const size_t hiExclusive, const size_t maxNumSamples, arma::uvec &distinctSamples)
Obtains no more than maxNumSamples distinct samples.
Definition: random.hpp:153
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
arma::Col< ElemType > direction
The normal vector to the hyperplane that splits the node.
Definition: rp_tree_max_split.hpp:41
This class splits a node by a random hyperplane.
Definition: rp_tree_max_split.hpp:32
double Random()
Generates a uniform random number between 0 and 1.
Definition: random.hpp:83
void RandVector(arma::vec &v)
Overwrites a dimension-N vector to a random vector on the unit sphere in R^N.
Definition: lin_alg.cpp:79
MatType::elem_type ElemType
The element type held by the matrix type.
Definition: rp_tree_max_split.hpp:36
An information about the partition.
Definition: rp_tree_max_split.hpp:38
static bool SplitNode(const BoundType &, MatType &data, const size_t begin, const size_t count, SplitInfo &splitInfo)
Split the node by a random hyperplane.
Definition: rp_tree_max_split_impl.hpp:23
ElemType splitVal
The value according to which the node is being split.
Definition: rp_tree_max_split.hpp:43