12 #ifndef MLPACK_METHODS_DECISION_STUMP_DECISION_STUMP_HPP
13 #define MLPACK_METHODS_DECISION_STUMP_DECISION_STUMP_HPP
18 namespace decision_stump {
33 template<
typename MatType = arma::mat>
47 const arma::Row<size_t>& labels,
49 const size_t bucketSize = 10);
64 const arma::Row<size_t>& labels,
65 const arma::rowvec& weights);
84 void Train(
const MatType& data,
85 const arma::Row<size_t>& labels,
87 const size_t bucketSize);
100 void Train(
const MatType& data,
101 const arma::Row<size_t>& labels,
102 const arma::rowvec& weights,
103 const size_t classes,
104 const size_t bucketSize);
114 void Classify(
const MatType& test, arma::Row<size_t>& predictedLabels);
122 const arma::vec&
Split()
const {
return split; }
124 arma::vec&
Split() {
return split; }
127 const arma::Col<size_t>
BinLabels()
const {
return binLabels; }
132 template<
typename Archive>
133 void Serialize(Archive& ar,
const unsigned int );
142 size_t splitDimension;
146 arma::Col<size_t> binLabels;
156 template<
bool UseWeights,
typename VecType>
157 double SetupSplitDimension(
const VecType& dimension,
158 const arma::Row<size_t>& labels,
159 const arma::rowvec& weightD);
168 template<
typename VecType>
169 void TrainOnDim(
const VecType& dimension,
170 const arma::Row<size_t>& labels);
184 template<
typename VecType>
185 double CountMostFreq(
const VecType& subCols);
192 template<
typename VecType>
193 int IsDistinct(
const VecType& featureRow);
204 template<
bool UseWeights,
typename VecType,
typename WeightVecType>
205 double CalculateEntropy(
const VecType& labels,
206 const WeightVecType& weights);
217 template<
bool UseWeights>
218 void Train(
const MatType& data,
219 const arma::Row<size_t>& labels,
220 const arma::rowvec& weights);
226 #include "decision_stump_impl.hpp"
The core includes that mlpack expects; standard C++ includes and Armadillo.
DecisionStump()
Create a decision stump without training.
This class implements a decision stump.
const arma::Col< size_t > BinLabels() const
Access the labels for each split bin.
arma::Col< size_t > & BinLabels()
Modify the labels for each split bin (be careful!).
size_t SplitDimension() const
Access the splitting dimension.
void Serialize(Archive &ar, const unsigned int)
Serialize the decision stump.
arma::vec & Split()
Modify the splitting values (be careful!).
size_t & SplitDimension()
Modify the splitting dimension (be careful!).
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.
void Classify(const MatType &test, arma::Row< size_t > &predictedLabels)
Classification function.