mlpack  master
best_binary_numeric_split.hpp
Go to the documentation of this file.
1 
7 #ifndef MLPACK_METHODS_DECISION_TREE_BEST_BINARY_NUMERIC_SPLIT_HPP
8 #define MLPACK_METHODS_DECISION_TREE_BEST_BINARY_NUMERIC_SPLIT_HPP
9 
10 #include <mlpack/prereqs.hpp>
11 
12 namespace mlpack {
13 namespace tree {
14 
21 template<typename FitnessFunction>
23 {
24  public:
25  // No extra info needed for split.
26  template<typename ElemType>
27  class AuxiliarySplitInfo { };
28 
48  template<typename VecType>
49  static double SplitIfBetter(
50  const double bestGain,
51  const VecType& data,
52  const arma::Row<size_t>& labels,
53  const size_t numClasses,
54  const size_t minimumLeafSize,
55  arma::Col<typename VecType::elem_type>& classProbabilities,
57 
61  template<typename ElemType>
62  static size_t NumChildren(const arma::Col<ElemType>& /* classProbabilities */,
63  const AuxiliarySplitInfo<ElemType>& /* aux */)
64  {
65  return 2;
66  }
67 
75  template<typename ElemType>
76  static size_t CalculateDirection(
77  const ElemType& point,
78  const arma::Col<ElemType>& classProbabilities,
79  const AuxiliarySplitInfo<ElemType>& /* aux */);
80 };
81 
82 } // namespace tree
83 } // namespace mlpack
84 
85 // Include implementation.
86 #include "best_binary_numeric_split_impl.hpp"
87 
88 #endif
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.
The BestBinaryNumericSplit is a splitting function for decision trees that will exhaustively search a...
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
static size_t NumChildren(const arma::Col< ElemType > &, const AuxiliarySplitInfo< ElemType > &)
Returns 2, since the binary split always has two children.
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).