>>> from mlpack import adaboost
This program implements the AdaBoost (or Adaptive Boosting) algorithm. The variant of AdaBoost implemented here is AdaBoost.MH. It uses a weak learner, either decision stumps or perceptrons, and over many iterations, creates a strong learner that is a weighted ensemble of weak learners. It runs these iterations until a tolerance value is crossed for change in the value of the weighted training error.
For more information about the algorithm, see the paper "Improved Boosting Algorithms Using Confidence-Rated Predictions", by R.E. Schapire and Y. Singer.
This program allows training of an AdaBoost model, and then application of that model to a test dataset. To train a model, a dataset must be passed with the 'training' option. Labels can be given with the 'labels' option; if no labels are specified, the labels will be assumed to be the last column of the input dataset. Alternately, an AdaBoost model may be loaded with the 'input_model' option.
Once a model is trained or loaded, it may be used to provide class predictions for a given test dataset. A test dataset may be specified with the 'test' parameter. The predicted classes for each point in the test dataset are output to the 'output' output parameter. The AdaBoost model itself is output to the 'output_model'output parameter.
For example, to run AdaBoost on an input dataset 'data' with perceptrons as the weak learner type, storing the trained model in 'model', one could use the following command:
>>> output = adaboost(training=data, weak_learner='perceptron')
>>> model = output['output_model']
Similarly, an already-trained model in 'model' can be used to provide class predictions from test data 'test_data' and store the output in 'predictions' with the following command:
>>> output = adaboost(input_model=model, test=test_data)
>>> predictions = output['output']
- copy_all_inputs (bool): If specified, all input parameters will be deep copied before the method is run. This is useful for debugging problems where the input parameters are being modified by the algorithm, but can slow down the code.
- input_model (mlpack.AdaBoostModelType): Input AdaBoost model.
- iterations (int): The maximum number of boosting iterations to be run (0 will run until convergence.) Default value 1000.
- labels (numpy vector or array, int/long dtype): Labels for the training set.
- test (numpy matrix or arraylike, float dtype): Test dataset.
- tolerance (float): The tolerance for change in values of the weighted error during training. Default value 1e-10.
- training (numpy matrix or arraylike, float dtype): Dataset for training AdaBoost.
- verbose (bool): Display informational messages and the full list of parameters and timers at the end of execution.
- weak_learner (string): The type of weak learner to use: 'decision_stump', or 'perceptron'. Default value decision_stump.
The return value from the binding is a dict containing the following elements:
- output (numpy vector, int dtype): Predicted labels for the test set.
- output_model (mlpack.AdaBoostModelType): Output trained AdaBoost model.