28 #ifndef MLPACK_METHODS_ADABOOST_ADABOOST_HPP
29 #define MLPACK_METHODS_ADABOOST_ADABOOST_HPP
79 template<
typename WeakLearnerType = mlpack::perceptron::Perceptron<>,
80 typename MatType = arma::mat>
98 const arma::Row<size_t>& labels,
99 const size_t numClasses,
100 const WeakLearnerType& other,
101 const size_t iterations = 100,
102 const double tolerance = 1e-6);
108 AdaBoost(
const double tolerance = 1e-6);
122 double Alpha(
const size_t i)
const {
return alpha[i]; }
124 double&
Alpha(
const size_t i) {
return alpha[i]; }
127 const WeakLearnerType&
WeakLearner(
const size_t i)
const {
return wl[i]; }
146 double Train(
const MatType& data,
147 const arma::Row<size_t>& labels,
148 const size_t numClasses,
149 const WeakLearnerType& learner,
150 const size_t iterations = 100,
151 const double tolerance = 1e-6);
163 arma::Row<size_t>& predictedLabels,
164 arma::mat& probabilities);
174 arma::Row<size_t>& predictedLabels);
179 template<
typename Archive>
180 void serialize(Archive& ar,
const unsigned int );
189 std::vector<WeakLearnerType> wl;
191 std::vector<double> alpha;
199 namespace serialization {
201 template<
typename WeakLearnerType,
typename MatType>
202 struct version<mlpack::adaboost::AdaBoost<WeakLearnerType, MatType>>
204 BOOST_STATIC_CONSTANT(
int, value = 1);
211 #include "adaboost_impl.hpp"
size_t WeakLearners() const
Get the number of weak learners in the model.
const WeakLearnerType & WeakLearner(const size_t i) const
Get the given weak learner.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t NumClasses() const
Get the number of classes this model is trained on.
AdaBoost(const MatType &data, const arma::Row< size_t > &labels, const size_t numClasses, const WeakLearnerType &other, const size_t iterations=100, const double tolerance=1e-6)
Constructor.
double & Alpha(const size_t i)
Modify the weight for the given weak learner (be careful!).
double Train(const MatType &data, const arma::Row< size_t > &labels, const size_t numClasses, const WeakLearnerType &learner, const size_t iterations=100, const double tolerance=1e-6)
Train AdaBoost on the given dataset.
void Classify(const MatType &test, arma::Row< size_t > &predictedLabels, arma::mat &probabilities)
Classify the given test points.
double & Tolerance()
Modify the tolerance for stopping the optimization during training.
void serialize(Archive &ar, const unsigned int)
Serialize the AdaBoost model.
WeakLearnerType & WeakLearner(const size_t i)
Modify the given weak learner (be careful!).
double Tolerance() const
Get the tolerance for stopping the optimization during training.
double Alpha(const size_t i) const
Get the weights for the given weak learner.