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,
66 const arma::Row<size_t>& labels,
67 const arma::rowvec& weights);
86 void Train(
const MatType& data,
87 const arma::Row<size_t>& labels,
99 void Classify(
const MatType& test, arma::Row<size_t>& predictedLabels);
117 template<
typename Archive>
118 void Serialize(Archive& ar,
const unsigned int );
141 template<
bool UseWeights>
143 const arma::Row<size_t>& labels,
144 const arma::rowvec& weightD);
153 template<
typename VecType>
155 const arma::Row<size_t>& labels);
169 template<
typename VecType>
177 template<
typename VecType>
189 template<
bool UseWeights,
typename VecType,
typename WeightVecType>
191 const WeightVecType& weights);
202 template<
bool UseWeights>
203 void Train(
const MatType& data,
204 const arma::Row<size_t>& labels,
205 const arma::rowvec& weights);
211 #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.
size_t splitDimension
Stores the value of the dimension 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!).
size_t SplitDimension() const
Access the splitting dimension.
int IsDistinct(const VecType &featureRow)
Returns 1 if all the values of featureRow are not same.
This class implements a decision stump.
double SetupSplitDimension(const arma::rowvec &dimension, const arma::Row< size_t > &labels, const arma::rowvec &weightD)
Sets up dimension as if it were splitting on it and finds entropy when splitting on dimension...
DecisionStump()
Create a decision stump without training.
const arma::vec & Split() const
Access the splitting values.
void Train(const MatType &data, const arma::Row< size_t > &labels, const size_t classes, const size_t bucketSize)
Train the decision stump on the given data.
arma::Col< size_t > binLabels
Stores the labels for each splitting bin.
void Serialize(Archive &ar, const unsigned int)
Serialize the decision stump.
size_t bucketSize
The minimum number of points in a bucket.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
double CalculateEntropy(const VecType &labels, const WeightVecType &weights)
Calculate the entropy of the given dimension.
arma::vec & Split()
Modify the splitting values (be careful!).
void TrainOnDim(const VecType &dimension, const arma::Row< size_t > &labels)
After having decided the dimension on which to split, train on that dimension.
size_t & SplitDimension()
Modify the splitting dimension (be careful!).
arma::vec split
Stores the splitting values after training.
const arma::Col< size_t > BinLabels() const
Access the labels for each split bin.
size_t classes
The number of classes (we must store this for boosting).
double CountMostFreq(const VecType &subCols)
Count the most frequently occurring element in subCols.