mlpack
2.0.1
|
Public Member Functions | |
AdaBoost (const MatType &data, const arma::Row< size_t > &labels, 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 | Alpha (const size_t i) const |
Get the weights for the given weak learner. More... | |
double & | Alpha (const size_t i) |
Modify the weight for the given weak learner (be careful!). More... | |
size_t | Classes () const |
Get the number of classes this model is trained on. 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 unsigned int) |
Serialize the AdaBoost model. More... | |
double | Tolerance () const |
Get the tolerance for stopping the optimization during training. More... | |
double & | Tolerance () |
Modify the tolerance for stopping the optimization during training. More... | |
void | Train (const MatType &data, const arma::Row< size_t > &labels, const WeakLearnerType &learner, const size_t iterations=100, const double tolerance=1e-6) |
Train AdaBoost on the given dataset. More... | |
const WeakLearnerType & | WeakLearner (const size_t i) const |
Get the given weak learner. More... | |
WeakLearnerType & | WeakLearner (const size_t i) |
Modify the given weak learner (be careful!). More... | |
size_t | WeakLearners () const |
Get the number of weak learners in the model. More... | |
double | ZtProduct () |
Private Attributes | |
std::vector< double > | alpha |
The weights corresponding to each weak learner. More... | |
size_t | classes |
The number of classes in the model. More... | |
double | tolerance |
std::vector< WeakLearnerType > | wl |
The vector of weak learners. More... | |
double | ztProduct |
To check for the bound for the Hamming loss. More... | |
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 decision_stump::DecisionStump<>.
MatType | Data matrix type (i.e. arma::mat or arma::sp_mat). |
WeakLearnerType | Type of weak learner to use. |
Definition at line 83 of file adaboost.hpp.
mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::AdaBoost | ( | const MatType & | data, |
const arma::Row< size_t > & | labels, | ||
const WeakLearnerType & | other, | ||
const size_t | iterations = 100 , |
||
const double | tolerance = 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. |
iterations | Number of boosting rounds. |
tol | The tolerance for change in values of rt. |
other | Weak learner that has already been initialized. |
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()!
|
inline |
Get the weights for the given weak learner.
Definition at line 125 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::alpha.
|
inline |
Modify the weight for the given weak learner (be careful!).
Definition at line 127 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::alpha.
|
inline |
Get the number of classes this model is trained on.
Definition at line 119 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::classes.
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 to the predicted labels of the test set will be stored. |
void mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::Serialize | ( | Archive & | ar, |
const unsigned | int | ||
) |
Serialize the AdaBoost model.
|
inline |
Get the tolerance for stopping the optimization during training.
Definition at line 114 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::tolerance.
|
inline |
Modify the tolerance for stopping the optimization during training.
Definition at line 116 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::tolerance.
void mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::Train | ( | const MatType & | data, |
const arma::Row< size_t > & | labels, | ||
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. |
learner | Learner to use for training. |
|
inline |
Get the given weak learner.
Definition at line 130 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::wl.
|
inline |
Modify the given weak learner (be careful!).
Definition at line 132 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::wl.
|
inline |
Get the number of weak learners in the model.
Definition at line 122 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::alpha.
|
inline |
Definition at line 111 of file adaboost.hpp.
References mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::ztProduct.
|
private |
The weights corresponding to each weak learner.
Definition at line 175 of file adaboost.hpp.
Referenced by mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::Alpha(), and mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::WeakLearners().
|
private |
The number of classes in the model.
Definition at line 168 of file adaboost.hpp.
Referenced by mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::Classes().
|
private |
Definition at line 170 of file adaboost.hpp.
Referenced by mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::Tolerance().
|
private |
The vector of weak learners.
Definition at line 173 of file adaboost.hpp.
Referenced by mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::WeakLearner().
|
private |
To check for the bound for the Hamming loss.
Definition at line 178 of file adaboost.hpp.
Referenced by mlpack::adaboost::AdaBoost< WeakLearnerType, MatType >::ZtProduct().