mlpack  2.0.1
binary_numeric_split.hpp
Go to the documentation of this file.
1 
15 #ifndef __MLPACK_METHODS_HOEFFDING_SPLIT_BINARY_NUMERIC_SPLIT_HPP
16 #define __MLPACK_METHODS_HOEFFDING_SPLIT_BINARY_NUMERIC_SPLIT_HPP
17 
19 
20 namespace mlpack {
21 namespace tree {
22 
47 template<typename FitnessFunction,
48  typename ObservationType = double>
50 {
51  public:
54 
60  BinaryNumericSplit(const size_t numClasses);
61 
68  BinaryNumericSplit(const size_t numClasses, const BinaryNumericSplit& other);
69 
76  void Train(ObservationType value, const size_t label);
77 
91  void EvaluateFitnessFunction(double& bestFitness,
92  double& secondBestFitness);
93 
94  // Return the number of children if this node were to split on this feature.
95  size_t NumChildren() const { return 2; }
96 
104  void Split(arma::Col<size_t>& childMajorities, SplitInfo& splitInfo);
105 
107  size_t MajorityClass() const;
109  double MajorityProbability() const;
110 
112  template<typename Archive>
113  void Serialize(Archive& ar, const unsigned int /* version */);
114 
115  private:
117  std::multimap<ObservationType, size_t> sortedElements;
119  arma::Col<size_t> classCounts;
120 
122  ObservationType bestSplit;
126 };
127 
128 // Convenience typedef.
129 template<typename FitnessFunction>
131 
132 } // namespace tree
133 } // namespace mlpack
134 
135 // Include implementation.
136 #include "binary_numeric_split_impl.hpp"
137 
138 #endif
BinaryNumericSplit(const size_t numClasses)
Create the BinaryNumericSplit object with the given number of classes.
Linear algebra utility functions, generally performed on matrices or vectors.
The BinaryNumericSplit class implements the numeric feature splitting strategy devised by Gama...
arma::Col< size_t > classCounts
The classes we have seen so far (for majority calculations).
ObservationType bestSplit
A cached best split point.
std::multimap< ObservationType, size_t > sortedElements
The elements seen so far, in sorted order.
BinaryNumericSplitInfo< ObservationType > SplitInfo
The splitting information required by the BinaryNumericSplit.
bool isAccurate
If true, the cached best split point is accurate (that is, we have not seen any more samples since we...
void Train(ObservationType value, const size_t label)
Train on the given value with the given label.
size_t MajorityClass() const
The majority class of the points seen so far.
void EvaluateFitnessFunction(double &bestFitness, double &secondBestFitness)
Given the points seen so far, evaluate the fitness function, returning the best possible gain of a bi...
void Split(arma::Col< size_t > &childMajorities, SplitInfo &splitInfo)
Given that a split should happen, return the majority classes of the (two) children and an initialize...
void Serialize(Archive &ar, const unsigned int)
Serialize the object.
double MajorityProbability() const
The probability of the majority class given the points seen so far.