iRoCS Toolbox
1.1.0
|
The TwoClassSVM class is the basic class for TwoClassSVMc and TwoClassSVMnu and maybe some more later. More...
#include <TwoClassSVM.hh>
Data Structures | |
struct | Traits |
Public Types | |
typedef KF | KF_type |
Public Member Functions | |
TwoClassSVM () | |
TwoClassSVM (const KF &kernel) | |
(description) More... | |
~TwoClassSVM () | |
(description) More... | |
float | cacheSizeMB () const |
template<typename FV , typename ForwardIter > | |
void | calcClassificationCache (const FV &testObject, const ForwardIter &SVP_begin, const ForwardIter &SVP_end, std::vector< double > &kernelResultByUID) const |
caculcate the Classification Cache kernelResultByUID, which contains kernel evaluations for classification. More... | |
template<typename FV , typename ForwardIter , typename FVGradient > | |
void | calcGradientCache (const FV &testObject, const ForwardIter &SVP_begin, const ForwardIter &SVP_end, std::vector< FVGradient > &gradientOfKernelResultByUID) const |
compute the gradient of the kernel Result for given testObject and support vectors. More... | |
template<typename FV > | |
double | classify (const FV &testObject, const Model< FV > &model) const |
standard classification without caching the kernel evaluations. More... | |
template<typename FV > | |
double | classifyWithCache (const Model< FV > &model, const std::vector< double > &kernelResultByUID) const |
classify testObject (that was passed to calcClassificationCache() before) using the given model.The kernel evaluations (kernelResulsByUID) must be computed before by calcClassificationCache. More... | |
void | clearKernelCache () const |
call the clearCache() method of selected Kernel More... | |
template<typename FV , typename FVGradient > | |
void | gradientOfDecisionFunction (const Model< FV > &model, const std::vector< FVGradient > &gradientOfKernelResultByUID, FVGradient &gradient) const |
compute the gradient of the decision function at testObject's position in the feature space for the given model. More... | |
KF & | kernel () |
access the kernel function More... | |
const KF & | kernel () const |
template<typename STDATA > | |
void | loadParameters (STDATA &stData) |
Load parameters from structured data object. More... | |
template<typename STDATA > | |
void | saveParameters (STDATA &stData) const |
save parameters to structured data object More... | |
void | setCacheSizeMB (float s) |
set cache memory size in MB (default: 40) More... | |
void | setProgressReporter (ProgressReporter *pr) |
set a progress reporter object. More... | |
void | setShrinkingFlag (bool f) |
whether to use the shrinking heuristics (default: true) More... | |
void | setTerminationEpsilon (double e) |
set tolerance of termination criterion (default: 0.001) More... | |
bool | shrinkingFlag () const |
double | terminationEpsilon () const |
template<typename ForwardIter , typename Accessor > | |
void | updateKernelCache (const ForwardIter &fvBegin, const ForwardIter &fvEnd, Accessor accessor) const |
call the updateCache() method of selected Kernel More... | |
Static Public Member Functions | |
static void | getParamInfos (std::vector< ParamInfo > &p) |
get information about the parameters, that are used in loadParameters() and saveParameters(). More... | |
Protected Attributes | |
float | _cacheSizeMB |
ProgressReporter * | _pr |
bool | _shrinkingFlag |
double | _terminationEpsilon |
KF | p_kernel |
The TwoClassSVM class is the basic class for TwoClassSVMc and TwoClassSVMnu and maybe some more later.
(description)
Definition at line 133 of file TwoClassSVM.hh.
typedef KF svt::TwoClassSVM< KF >::KF_type |
Definition at line 137 of file TwoClassSVM.hh.
|
inline |
Definition at line 151 of file TwoClassSVM.hh.
|
inline |
|
inline |
(description)
Definition at line 174 of file TwoClassSVM.hh.
void svt::TwoClassSVM< KF >::calcClassificationCache | ( | const FV & | testObject, |
const ForwardIter & | SVP_begin, | ||
const ForwardIter & | SVP_end, | ||
std::vector< double > & | kernelResultByUID | ||
) | const |
caculcate the Classification Cache kernelResultByUID, which contains kernel evaluations for classification.
This is separated from the classify method, because multiclass-algorithms often need the evaluated kernels multiple times. To identify the requested support vectors in classifyWithCache() each given support vector must provide a uniqueID() method, that returns a unique index (unsigend int) between 0 and kernelResultByUID.size()
testObject | feature vector of the test object |
SV_begin | begin of container with pointers to support vectors |
SV_end | end of container with pointers to support vectors |
kernelResultByUID | (output) vector with kernel evaluation results by uniqueID() of feature vector. Must have already the correct size! |
Definition at line 93 of file TwoClassSVM.hh.
Referenced by svt::TwoClassSVM< KF >::~TwoClassSVM().
double svt::TwoClassSVM< KF >::classifyWithCache | ( | const Model< FV > & | model, |
const std::vector< double > & | kernelResultByUID | ||
) | const |
classify testObject (that was passed to calcClassificationCache() before) using the given model.The kernel evaluations (kernelResulsByUID) must be computed before by calcClassificationCache.
model | model containing Support Vectors, alphas and rho. Each Support Vector must provide a uniqueID() method, to find the cached kernel evalutaion, that was calculated in calcClassificationCache() |
kernelResultByUID | vector with kernel evaluation results by uniqueID() of feature vector. |
Definition at line 118 of file TwoClassSVM.hh.
Referenced by svt::TwoClassSVM< KF >::~TwoClassSVM().
void svt::TwoClassSVM< KF >::calcGradientCache | ( | const FV & | testObject, |
const ForwardIter & | SVP_begin, | ||
const ForwardIter & | SVP_end, | ||
std::vector< FVGradient > & | gradientOfKernelResultByUID | ||
) | const |
compute the gradient of the kernel Result for given testObject and support vectors.
testObject | feature vector of the test object | |
SVP_begin | begin of container with pointers to support vectors | |
SVP_end | end of container with pointers to support vectors | |
[out] | gradientOfKernelResultByUID | (output) vector with gradient of kernel results for testObject and each given support vector. the std::vector container must have already the correct size and each FVGradient must already have the correctnumber of components. |
Referenced by svt::TwoClassSVM< KF >::~TwoClassSVM().
void svt::TwoClassSVM< KF >::gradientOfDecisionFunction | ( | const Model< FV > & | model, |
const std::vector< FVGradient > & | gradientOfKernelResultByUID, | ||
FVGradient & | gradient | ||
) | const |
compute the gradient of the decision function at testObject's position in the feature space for the given model.
The gradientOfKernelResultByUID must have been computed before by passing your testObject to calcGradientCache()
model | model containing Support Vectors, alphas and rho. Each Support Vector must provide a uniqueID() method | |
gradientOfKernelResultByUID | kernel gradient evaluations for the testObject with each support vector, computed with calcGradientCache() | |
[out] | gradient | resulting gradient of the decision function. the passed vector must already have the correct number of components |
Referenced by svt::TwoClassSVM< KF >::~TwoClassSVM().
|
inlineinherited |
access the kernel function
Definition at line 164 of file SVMBase.hh.
|
inlineinherited |
Definition at line 170 of file SVMBase.hh.
|
inlineinherited |
call the updateCache() method of selected Kernel
Definition at line 187 of file SVMBase.hh.
|
inlineinherited |
call the clearCache() method of selected Kernel
Definition at line 206 of file SVMBase.hh.
|
inherited |
standard classification without caching the kernel evaluations.
testObject | feature vector of the test object |
model | model containing Support Vectors, alphas and rho. |
Referenced by svt::SVMBase< KF >::clearKernelCache().
|
inlineinherited |
set tolerance of termination criterion (default: 0.001)
e | new value for epsilon |
Definition at line 236 of file SVMBase.hh.
|
inlineinherited |
Definition at line 241 of file SVMBase.hh.
Referenced by svt::SVMBase< KF >::saveParameters().
|
inlineinherited |
set cache memory size in MB (default: 40)
s | cache size in MBytes |
Definition at line 255 of file SVMBase.hh.
|
inlineinherited |
Definition at line 260 of file SVMBase.hh.
Referenced by svt::SVMBase< KF >::saveParameters().
|
inlineinherited |
whether to use the shrinking heuristics (default: true)
f | true = use shrinking heuristics |
Definition at line 274 of file SVMBase.hh.
|
inlineinherited |
Definition at line 279 of file SVMBase.hh.
Referenced by svt::SVMBase< KF >::saveParameters().
|
inlineinherited |
Load parameters from structured data object.
Definition at line 290 of file SVMBase.hh.
Referenced by svt::TwoClassSVMnu< KF >::loadParameters(), and svt::TwoClassSVMc< KF >::loadParameters().
|
inlineinherited |
save parameters to structured data object
Definition at line 306 of file SVMBase.hh.
Referenced by svt::TwoClassSVMnu< KF >::saveParameters(), and svt::TwoClassSVMc< KF >::saveParameters().
|
inlinestaticinherited |
get information about the parameters, that are used in loadParameters() and saveParameters().
The Infos are appended to the passed array
p | array of ParamInfos. The Infos will be appended to this array |
Definition at line 326 of file SVMBase.hh.
Referenced by svt::TwoClassSVMnu< KF >::getParamInfos(), and svt::TwoClassSVMc< KF >::getParamInfos().
|
inlineinherited |
set a progress reporter object.
Every time any progress is made in the training or classification, the reportProgress() method of this object is callled.
pr | pointer to an object with a child class of ProgressReporter or 0, if you don't want any more progress reporting. You are responsible, that your ProgressReporter object is not deleted during operation of MultiClassSVMOneVsOne |
Definition at line 358 of file SVMBase.hh.
|
protectedinherited |
Definition at line 366 of file SVMBase.hh.
Referenced by svt::SVMBase< KF >::clearKernelCache(), svt::SVMBase< KF >::kernel(), svt::SVMBase< KF >::loadParameters(), svt::SVMBase< KF >::saveParameters(), and svt::SVMBase< KF >::updateKernelCache().
|
protectedinherited |
Definition at line 367 of file SVMBase.hh.
Referenced by svt::SVMBase< KF >::loadParameters(), svt::SVMBase< KF >::setTerminationEpsilon(), and svt::SVMBase< KF >::terminationEpsilon().
|
protectedinherited |
Definition at line 368 of file SVMBase.hh.
Referenced by svt::SVMBase< KF >::cacheSizeMB(), svt::SVMBase< KF >::loadParameters(), and svt::SVMBase< KF >::setCacheSizeMB().
|
protectedinherited |
Definition at line 369 of file SVMBase.hh.
Referenced by svt::SVMBase< KF >::loadParameters(), svt::SVMBase< KF >::setShrinkingFlag(), and svt::SVMBase< KF >::shrinkingFlag().
|
protectedinherited |
Definition at line 370 of file SVMBase.hh.
Referenced by svt::SVMBase< KF >::setProgressReporter(), and svt::SVMBase< KF >::updateKernelCache().