mlpack  2.2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
best_binary_numeric_split.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_DECISION_TREE_BEST_BINARY_NUMERIC_SPLIT_HPP
13 #define MLPACK_METHODS_DECISION_TREE_BEST_BINARY_NUMERIC_SPLIT_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace tree {
19 
26 template<typename FitnessFunction>
28 {
29  public:
30  // No extra info needed for split.
31  template<typename ElemType>
32  class AuxiliarySplitInfo { };
33 
53  template<typename VecType>
54  static double SplitIfBetter(
55  const double bestGain,
56  const VecType& data,
57  const arma::Row<size_t>& labels,
58  const size_t numClasses,
59  const size_t minimumLeafSize,
60  arma::Col<typename VecType::elem_type>& classProbabilities,
62 
66  template<typename ElemType>
67  static size_t NumChildren(const arma::Col<ElemType>& /* classProbabilities */,
68  const AuxiliarySplitInfo<ElemType>& /* aux */)
69  {
70  return 2;
71  }
72 
80  template<typename ElemType>
81  static size_t CalculateDirection(
82  const ElemType& point,
83  const arma::Col<ElemType>& classProbabilities,
84  const AuxiliarySplitInfo<ElemType>& /* aux */);
85 };
86 
87 } // namespace tree
88 } // namespace mlpack
89 
90 // Include implementation.
91 #include "best_binary_numeric_split_impl.hpp"
92 
93 #endif
The BestBinaryNumericSplit is a splitting function for decision trees that will exhaustively search a...
The core includes that mlpack expects; standard C++ includes and Armadillo.
static size_t CalculateDirection(const ElemType &point, const arma::Col< ElemType > &classProbabilities, const AuxiliarySplitInfo< ElemType > &)
Given a point, calculate which child it should go to (left or right).
static size_t NumChildren(const arma::Col< ElemType > &, const AuxiliarySplitInfo< ElemType > &)
Returns 2, since the binary split always has two children.
static double SplitIfBetter(const double bestGain, const VecType &data, const arma::Row< size_t > &labels, const size_t numClasses, const size_t minimumLeafSize, arma::Col< typename VecType::elem_type > &classProbabilities, AuxiliarySplitInfo< typename VecType::elem_type > &aux)
Check if we can split a node.