#include <BaseLearner.h>
Inheritance diagram for BaseLearner:
Public Member Functions | |
BaseLearner () | |
The constructor. | |
virtual void | initOptions (nor_utils::Args &args) |
Set the arguments of the algorithm using the standard interface of the arguments. | |
virtual void | declareArguments (nor_utils::Args &args)=0 |
Declare weak-learner-specific arguments. | |
virtual BaseLearner * | create ()=0 |
Returns a new object of the derived type. | |
virtual InputData * | createInputData () |
Creates an InputData object that it is good for the weak learner. | |
virtual void | run (InputData *pData)=0 |
Run the learner to build the classifier on the given data. | |
virtual char | classify (InputData *pData, const int idx, const int classIdx)=0 |
Classify the data on the given example index and class using the learned classifier. | |
const double | getAlpha () const |
Get the value of alpha. | |
virtual void | save (ofstream &outputStream, const int numTabs=0) |
Serialize the object. | |
virtual void | load (nor_utils::StreamTokenizer &st) |
Unserialize the object. | |
Static Public Member Functions | |
static LearnersRegs & | RegisteredLearners () |
Map the registered basic learners. | |
Protected Member Functions | |
virtual void | setSmoothingVal (const double smoothingVal) |
Set the smoothing value for alpha. | |
virtual double | getAlpha (const double error) |
Compute alpha using the error. | |
virtual double | getAlpha (const double eps_min, const double eps_pls) |
Compute alpha with abstention. | |
virtual double | getAlpha (const double eps_min, const double eps_pls, double theta) |
Compute alpha with abstention and theta. | |
Protected Attributes | |
double | _smoothingVal |
The smoothing value for alpha. | |
double | _alpha |
The confidence in the current learner. | |
const double | _smallVal |
A small value. | |
Classes | |
class | LearnersRegs |
Holds the information about the registered learners. More... |
All the weak learners used by AdaBoost should inherit from this one.
Definition at line 51 of file BaseLearner.h.
|
The constructor. It initializes _smallVal to 1E-10, and _alpha to 0
Definition at line 150 of file BaseLearner.h. |
|
Classify the data on the given example index and class using the learned classifier.
Implemented in StumpLearner. Referenced by OutputInfo::outputEdge(), and AdaBoostLearner::updateWeights(). |
|
Returns a new object of the derived type. For instance the overriding of this method in SingleStumpLearner will be: return new SingleStumpLearner();
Implemented in MultiStumpLearner, and SingleStumpLearner. |
|
Creates an InputData object that it is good for the weak learner. Override it if the weak learner requires another type of data to be loaded (which must be an extension of InputData).
Reimplemented in StumpLearner. Definition at line 34 of file BaseLearner.cpp. Referenced by AdaBoostLearner::run(). |
|
Declare weak-learner-specific arguments. These arguments will be added to the list of arguments under the group specific of the weak learner. It is called automatically in main, when the list of arguments is built up. Use this method to declare the arguments that belongs to the weak learner only.
Implemented in StumpLearner. |
|
Compute alpha with abstention and theta. A helper function to compute the alpha for AdaBoost with abstention and with theta. The formula is:
Definition at line 55 of file BaseLearner.cpp. References BaseLearner::_smallVal, BaseLearner::getAlpha(), and nor_utils::is_zero(). |
|
Compute alpha with abstention. A helper function to compute the alpha for AdaBoost with abstention but no theta. The formula is:
where is a smoothing value to avoid the zero on the denominator in case of no error (eps_min == 0).
Definition at line 48 of file BaseLearner.cpp. References BaseLearner::_smoothingVal. |
|
Compute alpha using the error. A helper function to compute the alpha for the basic AdaBoost with no abstention and no theta. The formula is:
Definition at line 41 of file BaseLearner.cpp. |
|
Get the value of alpha. This must be computed by the algorithm in run()!
Definition at line 236 of file BaseLearner.h. References BaseLearner::_alpha. Referenced by StumpLearner::doFullAbstention(), StumpLearner::doGreedyAbstention(), BaseLearner::getAlpha(), StumpLearner::getEnergy(), and AdaBoostLearner::updateWeights(). |
|
Set the arguments of the algorithm using the standard interface of the arguments. Call this to set the arguments asked by the user.
Reimplemented in StumpLearner. Definition at line 160 of file BaseLearner.h. |
|
Unserialize the object. This method will load the information needed for the classification from the xml file loaded in a StreamTokenizer class.
Reimplemented in MultiStumpLearner, SingleStumpLearner, and StumpLearner. Definition at line 91 of file BaseLearner.cpp. References BaseLearner::_alpha. Referenced by StumpLearner::load(). |
|
Map the registered basic learners. This data is updated statically just by adding the macro REGISTER_LEARNER(X) where X is the name of the learner (which must match the class name) in the .cpp file. Example (in file StumpLearner.cpp): REGISTER_LEARNER(SingleStumpLearner)
Definition at line 134 of file BaseLearner.h. Referenced by AdaBoostLearner::AdaBoostLearner(), and AdaBoostLearner::run(). |
|
Run the learner to build the classifier on the given data.
Implemented in MultiStumpLearner, and SingleStumpLearner. |
|
Serialize the object. The object information needed for classification will be saved in xml format. This method should be overridden by the derived classes which will call the superclass first and then serialize their data.
Reimplemented in MultiStumpLearner, SingleStumpLearner, and StumpLearner. Definition at line 83 of file BaseLearner.cpp. References BaseLearner::_alpha, and Serialization::standardTag(). Referenced by Serialization::appendHypothesis(), and StumpLearner::save(). |
|
Set the smoothing value for alpha. It is used with the formula to compute alpha without regularization. To avoid smoothing following the paper "Improved Boosting Algorithms using Confidence-rated Predictions", page 11 (http://www.cs.princeton.edu/~schapire/uncompress-papers.cgi/SchapireSi98.ps) the value should be set to 1/n, where n is the number of examples.
Definition at line 274 of file BaseLearner.h. References BaseLearner::_smoothingVal. |
|
The smoothing value for alpha.
Definition at line 347 of file BaseLearner.h. Referenced by BaseLearner::getAlpha(), and BaseLearner::setSmoothingVal(). |