classPiiKernelAdatron
#include <PiiKernelAdatron.h>
An implementation of the Kernel Adatron algorithm.
Inherits PiiLearningAlgorithm< SampleSet >, PiiClassifier< SampleSet >
Description
The Kernel Adatron (KA) is a hyperplane classifier whose training algorithm can be seen as a hybrid between the Perceptron and the Support Vector Machine. The objective of the KA algorithm is to find a maximal margin hyperplane just like in SVM. The solution algorithm does not however involve quadratic programming, which makes the KA much faster to train than the SVM. It has been proven that the KA converges toward the optimal solution (the maximal margin hyperplane) with an exponentially fast rate of convergence. The predictive power of the KA is practically equivalent to that of the SVM, but its training algorithm is 10 to 100 times faster.
The decision function of the Kernel Adatron is
In the equation, M is the number of support vectors, i.e. the number of training samples with a non-zero weight after training. is a desicion threshold, k() denotes the kernel function, and y is the binary classification of a training sample (0 or 1).
Public types
|
typedef PiiSampleSet::Traits< SampleSet
>::ConstFeatureIterator
|
Constructors and destructor
|
( )
Constructs a new Kernel Adatron. |
|
|
Destroys the Kernel Adatron. |
Public member functions
|
virtual PiiClassification::LearnerCapabilities
|
( )
Returns 0. |
|
virtual double
|
(
Returns the classification of |
|
virtual bool
|
( )
Returns |
|
double
|
Returns the convergence threshold. |
|
double
|
Returns the current value of . |
|
int
|
( )
Returns the number of features in each feature vector. |
|
PiiKernelFunction< ConstFeatureIterator > *
|
( )
Returns the kernel function. |
|
virtual void
|
Runs the Kernel Adatron algorithm with the given samples and class labels. |
|
double
|
( )
Returns the learning rate. |
|
int
|
( )
Returns the maximum number of learning iterations. |
|
void
|
(
Sets the convergence threshold. |
|
void
|
(
Set the parameter to decisionThreshold. |
|
void
|
(
Sets the kernel function. |
|
void
|
(
Sets the learning rate. |
|
void
|
(
Sets the maximum number of iterations the algorithm will take. |
|
void
|
(
Sets the support vectors. |
|
void
|
Sets the weight vector. |
|
SampleSet
|
( )
Returns the support vectors. |
|
QVector<
double >
|
( )
Returns the weight vector. |
Function details
-
PiiKernelAdatron
()Constructs a new Kernel Adatron.
-
~PiiKernelAdatron
()Destroys the Kernel Adatron.
-
virtual PiiClassification::LearnerCapabilities capabilities
()[virtual]Returns 0.
The Kernel Adatron is a supervised classifier with no on-line learning capabilities.
Reimplemented from PiiLearningAlgorithm.
-
virtual double classify
(- ConstFeatureIterator featureVector
[virtual]Returns the classification of
featureVector(either 0 or 1), orNaNif the Kernel Adatron has not been trained yet.Reimplemented from PiiClassifier.
-
virtual bool converged
()[virtual]Returns
trueif learn() was called, and the learning algorithm converged to a solution,falseotherwise.The learning algorithm won't converge if the classes are not linearly separable in the feature space or if maxIterations() is reached before finding a solution.
Reimplemented from PiiLearningAlgorithm.
-
double convergenceThreshold
()Returns the convergence threshold.
-
double decisionThreshold
()Returns the current value of .
-
int featureCount
()Returns the number of features in each feature vector.
If the adatron has not been trained, zero will be returned.
-
PiiKernelFunction< ConstFeatureIterator > * kernelFunction
()Returns the kernel function.
-
virtual void learn
(- const SampleSet & samples
- const QVector< double > & labels
- const QVector< double > & weights = < double >()
[virtual]Runs the Kernel Adatron algorithm with the given samples and class labels.
Since the Kernel Adatron is a binary classifier, the class labels must be either ones or zeros. The weights will be ignored.
Reimplemented from PiiLearningAlgorithm.
-
double learningRate
()Returns the learning rate.
-
int maxIterations
()Returns the maximum number of learning iterations.
The default value is 100.
-
void setConvergenceThreshold
(- double convergenceThreshold
Sets the convergence threshold.
The objective of the Kernel Adatron is to maximize the margin between two classes. Internally, the margin is calculated so that its maximum value is one. The learning algorithm will stop once the margin is close enough to the optimum, i.e. when (1-margin) <= convergenceThreshold. The default value is 0.01.
-
void setDecisionThreshold
(- double decisionThreshold
Set the parameter to decisionThreshold.
-
void setKernelFunction
(- PiiKernelFunction< ConstFeatureIterator > * kernel
Sets the kernel function.
This class will take the ownership of kernel. The old kernel function will be deleted. The default kernel is a Gaussian kernel with unit variance.
-
void setLearningRate
(- double learningRate
Sets the learning rate.
The default value is 1.0, which usually gives good results. There are certain theoretical bounds on the learning rate, but only experimenting with this value will show its real effect.
-
void setMaxIterations
(- int maxIterations
Sets the maximum number of iterations the algorithm will take.
This value limits the number of times the whole sample set is iterated over.
-
void setSupportVectors
(- const SampleSet & supportVectors
Sets the support vectors.
The support vectors are usually not set manually, but using the learn() function.
-
void setWeights
Sets the weight vector.
The weighs are usually not assigned manually, but using the learn() function.
-
SampleSet supportVectors
()Returns the support vectors.
-
QVector< double > weights
()Returns the weight vector.
The number of weights is equal to the number of support vectors.
Add a note
Not a single note added yet. Be the first, add yours.