random_binary_numeric_split.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_DECISION_TREE_RANDOM_BINARY_NUMERIC_SPLIT_HPP
13 #define MLPACK_METHODS_DECISION_TREE_RANDOM_BINARY_NUMERIC_SPLIT_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace tree {
19 
27 template<typename FitnessFunction>
29 {
30  public:
31  // No extra info needed for split.
32  class AuxiliarySplitInfo { };
33 
78  template<bool UseWeights, typename VecType, typename WeightVecType>
79  static double SplitIfBetter(
80  const double bestGain,
81  const VecType& data,
82  const arma::Row<size_t>& labels,
83  const size_t numClasses,
84  const WeightVecType& weights,
85  const size_t minimumLeafSize,
86  const double minimumGainSplit,
87  arma::vec& splitInfo,
88  AuxiliarySplitInfo& aux,
89  const bool splitIfBetterGain = false);
90 
116  template<bool UseWeights, typename VecType, typename WeightVecType>
117  static double SplitIfBetter(
118  const double bestGain,
119  const VecType& data,
120  const arma::rowvec& responses,
121  const WeightVecType& weights,
122  const size_t minimumLeafSize,
123  const double minimumGainSplit,
124  double& splitInfo,
125  AuxiliarySplitInfo& aux,
126  FitnessFunction& fitnessFunction,
127  const bool splitIfBetterGain = false);
128 
136  static size_t NumChildren(const double& /* splitInfo */,
137  const AuxiliarySplitInfo& /* aux */)
138  {
139  return 2;
140  }
141 
149  template<typename ElemType>
150  static size_t CalculateDirection(
151  const ElemType& point,
152  const double& splitInfo,
153  const AuxiliarySplitInfo& /* aux */);
154 };
155 
156 } // namespace tree
157 } // namespace mlpack
158 
159 // Include implementation.
160 #include "random_binary_numeric_split_impl.hpp"
161 
162 #endif
The RandomBinaryNumericSplit is a splitting function for decision trees that will split based on a ra...
static size_t CalculateDirection(const ElemType &point, const double &splitInfo, const AuxiliarySplitInfo &)
Given a point, calculate which child it should go to (left or right).
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static double SplitIfBetter(const double bestGain, const VecType &data, const arma::Row< size_t > &labels, const size_t numClasses, const WeightVecType &weights, const size_t minimumLeafSize, const double minimumGainSplit, arma::vec &splitInfo, AuxiliarySplitInfo &aux, const bool splitIfBetterGain=false)
Check if we can split a node.
static size_t NumChildren(const double &, const AuxiliarySplitInfo &)
Returns 2, since the binary split always has two children.