classPiiBoostClassifier
#include <PiiBoostClassifier.h>
An generic implementation of a boosted classifier.
Inherits PiiLearningAlgorithm< SampleSet >, PiiClassifier< SampleSet >
Description
"Boosting" is actually not a classification method but rather a meta-algorithm that can be used to boost the performance of another classifier. It is required that the classifier to be boosted is able to learn weighted samples.
All boosting algorithms work by repeatedly applying a weak
classifier to weighted training samples. On each iteration,
misclassified samples gain more weight so that subsequently added
classifiers will focus on getting them right. The
FloatBoost algorithm also goes backwards and
eliminates already added classifiers if doing so would decrease
training error.
The boosting algorithm will quit when the maximum number of classifiers has been reached. The
FloatBoost algorithm will also quit if its exponential
loss function goes below a threshold. The output of the boosted
classifier is a weighted sum over the ensemble of weak classifiers:
Here,
is the ith weak
classifier. The weak classifiers are binary classifiers with all
but the multi-class AdaBoostM1 algorithm, which uses
weighted voting to find the winning class.
Classes
| class |
An interface for objects that create weak classifiers for PiiBoostClassifier. |
Public types
|
typedef PiiSampleSet::Traits< SampleSet
>::ConstFeatureIterator
|
Constructors and destructor
|
(
Create a new boosting classifier that uses factory to create the weak classifiers. |
|
Public member functions
|
( )
Returns the training/classification algorithm currently in use. |
|
|
virtual PiiClassification::LearnerCapabilities
|
( )
Returns |
|
int
|
( )
Returns the number of different classes in training data, or 0 if the classifier has not been trained. |
|
QList<
PiiClassifier<
SampleSet > * >
|
( )
|
|
virtual double
|
(
Classify the given feature vector. |
|
virtual bool
|
( )
Returns |
|
Factory *
|
( )
Returns the factory currently in use. |
|
int
|
( )
Returns the number of features, or 0 if the classifier has not been trained. |
|
virtual void
|
Runs the selected boosting algorithm on samples. |
|
int
|
( )
Returns the maximum number of classifiers that will be combined. |
|
double
|
( )
Returns the error limit. |
|
void
|
Sets the algorithm used in training and classification. |
|
void
|
Sets the factory used for creating weak learners during batch training. |
|
void
|
(
Sets the maximum number of classifiers learn() will create. |
|
void
|
(
Sets the minimum training error. |
|
QList<
float >
|
( )
|
Protected member functions
|
static QString
|
(
|
Function details
-
PiiBoostClassifier
(- Factory * factory = 0
- PiiClassification::BoostingAlgorithm algorithm = PiiClassification::RealBoost
Create a new boosting classifier that uses factory to create the weak classifiers.
The learning algorithm will be set to algorithm. This class will not own factory; the pointer must be deleted by the caller.
-
~PiiBoostClassifier
() -
PiiClassification::BoostingAlgorithm algorithm
()Returns the training/classification algorithm currently in use.
-
virtual PiiClassification::LearnerCapabilities capabilities
()[virtual]Returns
WeightedLearner.Reimplemented from PiiLearningAlgorithm.
-
int classCount
()Returns the number of different classes in training data, or 0 if the classifier has not been trained.
This value will be set before weak learners are being created and can therefore be used by the factory object.
-
QList< PiiClassifier< SampleSet > * > classifiers
() -
virtual double classify
(- ConstFeatureIterator featureVector
[virtual]Classify the given feature vector.
The algorithm may vary from a simple nearest neighbor rule to support vector regression. The only requirement is that the classifier yields a class index or a continuous regression as a result. Errors are indicated by returning a NaN.
Parameters
- featureVector
-
the feature vector of the sample to be classified
Returns
a zero-based class index in classification, or a value in [0,1] in regression. NaN means that the sample could not be classified.
Reimplemented from PiiClassifier.
-
virtual bool converged
()[virtual]Returns
trueif the algorithm has converged (found an optimal solution) andfalseotherwise.Reimplemented from PiiLearningAlgorithm.
-
Factory * factory
()Returns the factory currently in use.
-
int featureCount
()Returns the number of features, or 0 if the classifier has not been trained.
This value will be set before weak learners are being created and can therefore be used by the factory object.
-
virtual void learn
(- const SampleSet & samples
- const QVector< double > & labels
- const QVector< double > & weights = < double >()
[virtual]Runs the selected boosting algorithm on samples.
Parameters
- samples
-
training samples
- labels
-
a class label for each training sample
- weights
-
initial weights for each training sample. This list can be left empty, in which case the initial weights will be automatically calculated.
Reimplemented from PiiLearningAlgorithm.
-
int maxClassifiers
()Returns the maximum number of classifiers that will be combined.
-
double minError
()Returns the error limit.
-
void setAlgorithm
Sets the algorithm used in training and classification.
It is possible to change the value between training and classification, if care is taken. For example, it is possible to train the classifier with
FloatBoostwhile using the multi-class generalizationAdaBoostM1for classification. -
void setFactory
Sets the factory used for creating weak learners during batch training.
The factory is used in creating a new weak learner on each boosting iteration. The caller owns the factor; this class doesn't delete the pointer.
-
void setMaxClassifiers
(- int maxClassifiers
Sets the maximum number of classifiers learn() will create.
The default value is 100.
-
void setMinError
(- double minError
Sets the minimum training error.
Training will be stopped once the weighted training error goes below this value. The default is zero.
-
QList< float > weights
() -
Add a note
Not a single note added yet. Be the first, add yours.