14 #ifndef __MLPACK_METHODS_DECISION_STUMP_DECISION_STUMP_HPP
15 #define __MLPACK_METHODS_DECISION_STUMP_DECISION_STUMP_HPP
20 namespace decision_stump {
35 template <
typename MatType = arma::mat>
49 const arma::Row<size_t>& labels,
51 size_t inpBucketSize);
61 void Classify(
const MatType& test, arma::Row<size_t>& predictedLabels);
77 const arma::rowvec& weights,
78 const arma::Row<size_t>& labels);
119 template <
bool isWeight>
121 const arma::Row<size_t>& labels,
122 const arma::rowvec& weightD);
131 template <
typename rType>
void TrainOnAtt(
const arma::rowvec& attribute,
132 const arma::Row<size_t>& labels);
146 template <
typename rType> rType
CountMostFreq(
const arma::Row<rType>&
154 template <
typename rType>
int IsDistinct(
const arma::Row<rType>& featureRow);
163 template <
typename LabelType,
bool isWeight>
165 const arma::rowvec& tempD);
174 template <
bool isWeight>
175 void Train(
const MatType& data,
const arma::Row<size_t>& labels,
176 const arma::rowvec& weightD);
183 #include "decision_stump_impl.hpp"
void MergeRanges()
After the "split" matrix has been set up, merge ranges with identical class labels.
void Classify(const MatType &test, arma::Row< size_t > &predictedLabels)
Classification function.
int splitAttribute
Stores the value of the attribute on which to split.
Linear algebra utility functions, generally performed on matrices or vectors.
arma::Col< size_t > & BinLabels()
Modify the labels for each split bin (be careful!).
void Train(const MatType &data, const arma::Row< size_t > &labels, const arma::rowvec &weightD)
Train the decision stump on the given data and labels.
size_t numClass
Stores the number of classes.
double SetupSplitAttribute(const arma::rowvec &attribute, const arma::Row< size_t > &labels, const arma::rowvec &weightD)
Sets up attribute as if it were splitting on it and finds entropy when splitting on attribute...
This class implements a decision stump.
const arma::vec & Split() const
Access the splitting values.
arma::Col< size_t > binLabels
Stores the labels for each splitting bin.
size_t bucketSize
Size of bucket while determining splitting criterion.
void TrainOnAtt(const arma::rowvec &attribute, const arma::Row< size_t > &labels)
After having decided the attribute on which to split, train on that attribute.
int SplitAttribute() const
Access the splitting attribute.
rType CountMostFreq(const arma::Row< rType > &subCols)
Count the most frequently occurring element in subCols.
int IsDistinct(const arma::Row< rType > &featureRow)
Returns 1 if all the values of featureRow are not same.
arma::vec & Split()
Modify the splitting values (be careful!).
double CalculateEntropy(arma::subview_row< LabelType > labels, int begin, const arma::rowvec &tempD)
Calculate the entropy of the given attribute.
int & SplitAttribute()
Modify the splitting attribute (be careful!).
arma::vec split
Stores the splitting values after training.
DecisionStump(const MatType &data, const arma::Row< size_t > &labels, const size_t classes, size_t inpBucketSize)
Constructor.
const arma::Col< size_t > BinLabels() const
Access the labels for each split bin.