MLPACK  1.0.10
decision_stump.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_METHODS_DECISION_STUMP_DECISION_STUMP_HPP
23 #define __MLPACK_METHODS_DECISION_STUMP_DECISION_STUMP_HPP
24 
25 #include <mlpack/core.hpp>
26 
27 namespace mlpack {
28 namespace decision_stump {
29 
43 template <typename MatType = arma::mat>
45 {
46  public:
56  DecisionStump(const MatType& data,
57  const arma::Row<size_t>& labels,
58  const size_t classes,
59  size_t inpBucketSize);
60 
69  void Classify(const MatType& test, arma::Row<size_t>& predictedLabels);
70 
77  DecisionStump(const DecisionStump<>& ds);
78 
89 
90  int SplitAttribute() const { return splitAttribute; }
92  int& SplitAttribute() { return splitAttribute; }
93 
95  const arma::vec& Split() const { return split; }
97  arma::vec& Split() { return split; }
98 
100  const arma::Col<size_t> BinLabels() const { return binLabels; }
102  arma::Col<size_t>& BinLabels() { return binLabels; }
103 
104  private:
106  size_t numClass;
107 
110 
112  size_t bucketSize;
113 
115  arma::vec split;
116 
118  arma::Col<size_t> binLabels;
119 
127  double SetupSplitAttribute(const arma::rowvec& attribute,
128  const arma::Row<size_t>& labels);
129 
137  template <typename rType> void TrainOnAtt(const arma::rowvec& attribute,
138  const arma::Row<size_t>& labels);
139 
144  void MergeRanges();
145 
152  template <typename rType> rType CountMostFreq(const arma::Row<rType>& subCols);
153 
159  template <typename rType> int IsDistinct(const arma::Row<rType>& featureRow);
160 
167  template <typename AttType, typename LabelType>
168  double CalculateEntropy(arma::subview_row<LabelType> labels);
169 };
170 
171 }; // namespace decision_stump
172 }; // namespace mlpack
173 
174 #include "decision_stump_impl.hpp"
175 
176 #endif