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,
48 const size_t numClasses,
49 const size_t bucketSize = 10);
64 const arma::Row<size_t>& labels,
65 const size_t numClasses,
66 const arma::rowvec& weights);
85 void Train(
const MatType& data,
86 const arma::Row<size_t>& labels,
87 const size_t numClasses,
88 const size_t bucketSize);
101 void Train(
const MatType& data,
102 const arma::Row<size_t>& labels,
103 const arma::rowvec& weights,
104 const size_t numClasses,
105 const size_t bucketSize);
115 void Classify(
const MatType& test, arma::Row<size_t>& predictedLabels);
123 const arma::vec&
Split()
const {
return split; }
125 arma::vec&
Split() {
return split; }
128 const arma::Col<size_t>
BinLabels()
const {
return binLabels; }
133 template<
typename Archive>
134 void serialize(Archive& ar,
const unsigned int );
143 size_t splitDimension;
147 arma::Col<size_t> binLabels;
157 template<
bool UseWeights,
typename VecType>
158 double SetupSplitDimension(
const VecType& dimension,
159 const arma::Row<size_t>& labels,
160 const arma::rowvec& weightD);
169 template<
typename VecType>
170 void TrainOnDim(
const VecType& dimension,
171 const arma::Row<size_t>& labels);
185 template<
typename VecType>
186 double CountMostFreq(
const VecType& subCols);
193 template<
typename VecType>
194 int IsDistinct(
const VecType& featureRow);
205 template<
bool UseWeights,
typename VecType,
typename WeightVecType>
206 double CalculateEntropy(
const VecType& labels,
207 const WeightVecType& weights);
218 template<
bool UseWeights>
219 void Train(
const MatType& data,
220 const arma::Row<size_t>& labels,
221 const arma::rowvec& weights);
227 #include "decision_stump_impl.hpp" void serialize(Archive &ar, const unsigned int)
Serialize the decision stump.
size_t SplitDimension() const
Access the splitting dimension.
The core includes that mlpack expects; standard C++ includes and Armadillo.
DecisionStump()
Create a decision stump without training.
This class implements a decision stump.
void Train(const MatType &data, const arma::Row< size_t > &labels, const size_t numClasses, const size_t bucketSize)
Train the decision stump on the given data.
arma::Col< size_t > & BinLabels()
Modify the labels for each split bin (be careful!).
const arma::Col< size_t > BinLabels() const
Access the labels for each split bin.
arma::vec & Split()
Modify the splitting values (be careful!).
size_t & SplitDimension()
Modify the splitting dimension (be careful!).
void Classify(const MatType &test, arma::Row< size_t > &predictedLabels)
Classification function.
const arma::vec & Split() const
Access the splitting values.