#include <StumpLearner.h>
Inheritance diagram for StumpLearner:
Public Member Functions | |
StumpLearner () | |
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) |
Declare weak-learner-specific arguments. | |
virtual InputData * | createInputData () |
Creates an InputData object that it is good for the weak learner. | |
virtual char | classify (InputData *pData, const int idx, const int classIdx) |
Return {+1, -1} for the given class and value using the learned classifier. | |
virtual void | save (ofstream &outputStream, const int numTabs=0) |
Save the current object information needed for classification, that is: _v, The alignment vector and _selectedColumn, the column of the data with that yielded the lowest error. | |
virtual void | load (nor_utils::StreamTokenizer &st) |
Load the xml file that contains the serialized information needed for the classification and that belongs to this class. | |
Protected Types | |
enum | eAbstType { ABST_NO_ABSTENTION, ABST_GREEDY, ABST_FULL } |
The type of abstention. More... | |
Protected Member Functions | |
virtual char | phi (double val, int classIdx)=0 |
A discriminative function. | |
virtual double | getEnergy (vector< sRates > &mu, double &alpha, vector< char > &v) |
Return the energy of the current learner. | |
virtual double | doGreedyAbstention (vector< sRates > &mu, double currEnergy, sRates &eps, double &alpha, vector< char > &v) |
Updates the v vector (alignment vector) using a greedy abstention algorithm. | |
virtual double | doFullAbstention (const vector< sRates > &mu, double currEnergy, sRates &eps, double &alpha, vector< char > &v) |
Updates the v vector (alignment vector) evaluating all the possible combinations. | |
Protected Attributes | |
vector< char > | _v |
The class-wise abstention/alignment vector. | |
int | _selectedColumn |
The column of the training data with the lowest error. | |
double | _theta |
the value of theta. Default = 0; | |
eAbstType | _abstention |
Activate abstention. Default = 0 (no abstention);. | |
vector< double > | _rightErrors |
the class-wise errors on the right side of the threshold. | |
vector< double > | _leftErrors |
the class-wise errors on the left side of the threshold. | |
vector< double > | _bestErrors |
the errors of the best found threshold. | |
vector< double > | _weightsPerClass |
The total weight per class. | |
vector< double > | _halfWeightsPerClass |
The half of the total weights per class. | |
Classes | |
struct | sRates |
The per class rates. More... |
Definition at line 50 of file StumpLearner.h.
|
The type of abstention.
Definition at line 255 of file StumpLearner.h. |
|
The constructor. It initializes theta to zero and the abstention to false (that is, their default values).
Definition at line 59 of file StumpLearner.h. |
|
Return {+1, -1} for the given class and value using the learned classifier.
Implements BaseLearner. Definition at line 81 of file StumpLearner.cpp. References StumpLearner::_selectedColumn, StumpLearner::_v, InputData::getValue(), and StumpLearner::phi(). |
|
Creates an InputData object that it is good for the weak learner. Overrided to return SortedData.
Reimplemented from BaseLearner. Definition at line 74 of file StumpLearner.cpp. |
|
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. This class declares the argument "-abstention" only.
Implements BaseLearner. Definition at line 64 of file StumpLearner.cpp. References Args::declareArgument(). |
|
Updates the v vector (alignment vector) evaluating all the possible combinations. Again we do not leave the abstention to the weak learner but we add 0 to the alignment vector v, which decreases most the energy function.
Definition at line 210 of file StumpLearner.cpp. References BaseLearner::_smallVal, BaseLearner::getAlpha(), ClassMappings::getNumClasses(), nor_utils::is_zero(), StumpLearner::sRates::rMin, StumpLearner::sRates::rPls, and StumpLearner::sRates::rZero. Referenced by StumpLearner::getEnergy(). |
|
Updates the v vector (alignment vector) using a greedy abstention algorithm. We do not leave the decision to the weak learner as usual, but we add 0 to the decisions of the alignment vector v. This is done by optimizing the energy value with a greedy algorithm (that, for the time being, is not proved to be optimal. We first get v from one of the stump algorithms (see for instance SingleStumpLearner::findThreshold()). Then, in an iteration over the classes, we select the "best" element of v to set to 0, that is, the one that decreases the energy the most.
Definition at line 142 of file StumpLearner.cpp. References BaseLearner::_smallVal, BaseLearner::getAlpha(), ClassMappings::getNumClasses(), nor_utils::is_zero(), StumpLearner::sRates::rMin, StumpLearner::sRates::rPls, and StumpLearner::sRates::rZero. Referenced by StumpLearner::getEnergy(). |
|
Return the energy of the current learner. The energy is defined as
and it is the value to minimize.
Definition at line 88 of file StumpLearner.cpp. References StumpLearner::_abstention, BaseLearner::_smallVal, StumpLearner::_theta, StumpLearner::ABST_FULL, StumpLearner::ABST_GREEDY, StumpLearner::ABST_NO_ABSTENTION, StumpLearner::doFullAbstention(), StumpLearner::doGreedyAbstention(), BaseLearner::getAlpha(), ClassMappings::getNumClasses(), nor_utils::is_zero(), StumpLearner::sRates::rMin, and StumpLearner::sRates::rPls. |
|
Set the arguments of the algorithm using the standard interface of the arguments. Call this to set the arguments asked by the user.
Reimplemented from BaseLearner. Definition at line 38 of file StumpLearner.cpp. References StumpLearner::_abstention, StumpLearner::_theta, StumpLearner::ABST_FULL, StumpLearner::ABST_GREEDY, Args::getValue(), and Args::hasArgument(). |
|
Load the xml file that contains the serialized information needed for the classification and that belongs to this class.
Reimplemented from BaseLearner. Reimplemented in MultiStumpLearner, and SingleStumpLearner. Definition at line 302 of file StumpLearner.cpp. References StumpLearner::_selectedColumn, StumpLearner::_v, BaseLearner::load(), and UnSerialization::seekAndParseVectorTag(). Referenced by SingleStumpLearner::load(), and MultiStumpLearner::load(). |
|
A discriminative function.
Implemented in MultiStumpLearner, and SingleStumpLearner. Referenced by StumpLearner::classify(). |
|
Save the current object information needed for classification, that is: _v, The alignment vector and _selectedColumn, the column of the data with that yielded the lowest error.
Reimplemented from BaseLearner. Reimplemented in MultiStumpLearner, and SingleStumpLearner. Definition at line 286 of file StumpLearner.cpp. References StumpLearner::_selectedColumn, StumpLearner::_v, BaseLearner::save(), Serialization::standardTag(), and Serialization::vectorTag(). Referenced by SingleStumpLearner::save(), and MultiStumpLearner::save(). |
|
The class-wise abstention/alignment vector. It is obtained simply with
where are defined in sMu.
Definition at line 244 of file StumpLearner.h. Referenced by StumpLearner::classify(), StumpLearner::load(), and StumpLearner::save(). |