mlpack
|
#include <adaboost.hpp>
Public Member Functions | |
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. More... | |
AdaBoost (const double tolerance=1e-6) | |
Create the AdaBoost object without training. More... | |
double | Tolerance () const |
Get the tolerance for stopping the optimization during training. | |
double & | Tolerance () |
Modify the tolerance for stopping the optimization during training. | |
size_t | NumClasses () const |
Get the number of classes this model is trained on. | |
size_t | WeakLearners () const |
Get the number of weak learners in the model. | |
double | Alpha (const size_t i) const |
Get the weights for the given weak learner. | |
double & | Alpha (const size_t i) |
Modify the weight for the given weak learner (be careful!). | |
const WeakLearnerType & | WeakLearner (const size_t i) const |
Get the given weak learner. | |
WeakLearnerType & | WeakLearner (const size_t i) |
Modify 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. More... | |
void | Classify (const MatType &test, arma::Row< size_t > &predictedLabels, arma::mat &probabilities) |
Classify the given test points. More... | |
void | Classify (const MatType &test, arma::Row< size_t > &predictedLabels) |
Classify the given test points. More... | |
template<typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the AdaBoost model. | |
The AdaBoost class.
AdaBoost is a boosting algorithm, meaning that it combines an ensemble of weak learners to produce a strong learner. For more information on AdaBoost, see the following paper:
This class is general, and can be used with any type of weak learner, so long as the learner implements the following functions:
For more information on and examples of weak learners, see perceptron::Perceptron<> and tree::ID3DecisionStump.
MatType | Data matrix type (i.e. arma::mat or arma::sp_mat). |
WeakLearnerType | Type of weak learner to use. |
mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::AdaBoost | ( | const MatType & | data, |
const arma::Row< size_t > & | labels, | ||
const size_t | numClasses, | ||
const WeakLearnerType & | other, | ||
const size_t | iterations = 100 , |
||
const double | tol = 1e-6 |
||
) |
Constructor.
This runs the AdaBoost.MH algorithm to provide a trained boosting model. This constructor takes an already-initialized weak learner; all other weak learners will learn with the same parameters as the given weak learner.
data | Input data. |
labels | Corresponding labels. |
numClasses | The number of classes. |
iterations | Number of boosting rounds. |
tolerance | The tolerance for change in values of rt. |
other | Weak learner that has already been initialized. |
Currently runs the AdaBoost.MH algorithm.
data | Input data |
labels | Corresponding labels |
iterations | Number of boosting rounds |
tol | Tolerance for termination of Adaboost.MH. |
other | Weak Learner, which has been initialized already. |
mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::AdaBoost | ( | const double | tolerance = 1e-6 | ) |
Create the AdaBoost object without training.
Be sure to call Train() before calling Classify()!
void mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::Classify | ( | const MatType & | test, |
arma::Row< size_t > & | predictedLabels, | ||
arma::mat & | probabilities | ||
) |
Classify the given test points.
test | Testing data. |
predictedLabels | Vector in which the predicted labels of the test set will be stored. |
probabilities | matrix to store the predicted class probabilities for each point in the test set. |
void mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::Classify | ( | const MatType & | test, |
arma::Row< size_t > & | predictedLabels | ||
) |
Classify the given test points.
test | Testing data. |
predictedLabels | Vector in which the predicted labels of the test set will be stored. |
double mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::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.
This method takes an initialized WeakLearnerType; the parameters for this weak learner will be used to train each of the weak learners during AdaBoost training. Note that this will completely overwrite any model that has already been trained with this object.
data | Dataset to train on. |
labels | Labels for each point in the dataset. |
numClasses | The number of classes. |
learner | Learner to use for training. |
iterations | Number of boosting rounds. |
tolerance | The tolerance for change in values of rt. |