iRoCS Toolbox  1.1.0
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
svt::TwoClassSVM< KF > Class Template Reference

The TwoClassSVM class is the basic class for TwoClassSVMc and TwoClassSVMnu and maybe some more later. More...

#include <TwoClassSVM.hh>

Inheritance diagram for svt::TwoClassSVM< KF >:
Collaboration diagram for svt::TwoClassSVM< KF >:

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
 

Detailed Description

template<typename KF>
class svt::TwoClassSVM< KF >

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.

Member Typedef Documentation

◆ KF_type

template<typename KF >
typedef KF svt::TwoClassSVM< KF >::KF_type

Definition at line 137 of file TwoClassSVM.hh.

Constructor & Destructor Documentation

◆ TwoClassSVM() [1/2]

template<typename KF >
svt::TwoClassSVM< KF >::TwoClassSVM ( )
inline

Definition at line 151 of file TwoClassSVM.hh.

◆ TwoClassSVM() [2/2]

template<typename KF >
svt::TwoClassSVM< KF >::TwoClassSVM ( const KF &  kernel)
inline

(description)

Parameters

Definition at line 163 of file TwoClassSVM.hh.

◆ ~TwoClassSVM()

template<typename KF >
svt::TwoClassSVM< KF >::~TwoClassSVM ( )
inline

(description)

Definition at line 174 of file TwoClassSVM.hh.

Member Function Documentation

◆ calcClassificationCache()

template<typename KF >
template<typename FV , typename ForwardIter >
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()

Parameters
testObjectfeature vector of the test object
SV_beginbegin of container with pointers to support vectors
SV_endend 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().

◆ classifyWithCache()

template<typename KF >
template<typename FV >
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.

Parameters
modelmodel 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()
kernelResultByUIDvector with kernel evaluation results by uniqueID() of feature vector.
Returns
decision value

Definition at line 118 of file TwoClassSVM.hh.

Referenced by svt::TwoClassSVM< KF >::~TwoClassSVM().

◆ calcGradientCache()

template<typename KF >
template<typename FV , typename ForwardIter , typename FVGradient >
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.

Parameters
testObjectfeature vector of the test object
SVP_beginbegin of container with pointers to support vectors
SVP_endend 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().

◆ gradientOfDecisionFunction()

template<typename KF >
template<typename FV , typename FVGradient >
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()

Parameters
modelmodel containing Support Vectors, alphas and rho. Each Support Vector must provide a uniqueID() method
gradientOfKernelResultByUIDkernel gradient evaluations for the testObject with each support vector, computed with calcGradientCache()
[out]gradientresulting gradient of the decision function. the passed vector must already have the correct number of components

Referenced by svt::TwoClassSVM< KF >::~TwoClassSVM().

◆ kernel() [1/2]

template<typename KF >
KF& svt::SVMBase< KF >::kernel ( )
inlineinherited

access the kernel function

Returns
reference to kernel function

Definition at line 164 of file SVMBase.hh.

◆ kernel() [2/2]

template<typename KF >
const KF& svt::SVMBase< KF >::kernel ( ) const
inlineinherited

Definition at line 170 of file SVMBase.hh.

◆ updateKernelCache()

template<typename KF >
template<typename ForwardIter , typename Accessor >
void svt::SVMBase< KF >::updateKernelCache ( const ForwardIter &  fvBegin,
const ForwardIter &  fvEnd,
Accessor  accessor 
) const
inlineinherited

call the updateCache() method of selected Kernel

Parameters

Definition at line 187 of file SVMBase.hh.

◆ clearKernelCache()

template<typename KF >
void svt::SVMBase< KF >::clearKernelCache ( ) const
inlineinherited

call the clearCache() method of selected Kernel

Parameters

Definition at line 206 of file SVMBase.hh.

◆ classify()

template<typename KF >
template<typename FV >
double svt::SVMBase< KF >::classify ( const FV &  testObject,
const Model< FV > &  model 
) const
inherited

standard classification without caching the kernel evaluations.

Parameters
testObjectfeature vector of the test object
modelmodel containing Support Vectors, alphas and rho.
Returns
decision value

Referenced by svt::SVMBase< KF >::clearKernelCache().

◆ setTerminationEpsilon()

template<typename KF >
void svt::SVMBase< KF >::setTerminationEpsilon ( double  e)
inlineinherited

set tolerance of termination criterion (default: 0.001)

Parameters
enew value for epsilon

Definition at line 236 of file SVMBase.hh.

◆ terminationEpsilon()

template<typename KF >
double svt::SVMBase< KF >::terminationEpsilon ( ) const
inlineinherited

Definition at line 241 of file SVMBase.hh.

Referenced by svt::SVMBase< KF >::saveParameters().

◆ setCacheSizeMB()

template<typename KF >
void svt::SVMBase< KF >::setCacheSizeMB ( float  s)
inlineinherited

set cache memory size in MB (default: 40)

Parameters
scache size in MBytes

Definition at line 255 of file SVMBase.hh.

◆ cacheSizeMB()

template<typename KF >
float svt::SVMBase< KF >::cacheSizeMB ( ) const
inlineinherited

Definition at line 260 of file SVMBase.hh.

Referenced by svt::SVMBase< KF >::saveParameters().

◆ setShrinkingFlag()

template<typename KF >
void svt::SVMBase< KF >::setShrinkingFlag ( bool  f)
inlineinherited

whether to use the shrinking heuristics (default: true)

Parameters
ftrue = use shrinking heuristics

Definition at line 274 of file SVMBase.hh.

◆ shrinkingFlag()

template<typename KF >
bool svt::SVMBase< KF >::shrinkingFlag ( ) const
inlineinherited

Definition at line 279 of file SVMBase.hh.

Referenced by svt::SVMBase< KF >::saveParameters().

◆ loadParameters()

template<typename KF >
template<typename STDATA >
void svt::SVMBase< KF >::loadParameters ( STDATA &  stData)
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().

◆ saveParameters()

template<typename KF >
template<typename STDATA >
void svt::SVMBase< KF >::saveParameters ( STDATA &  stData) const
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().

◆ getParamInfos()

template<typename KF >
static void svt::SVMBase< KF >::getParamInfos ( std::vector< ParamInfo > &  p)
inlinestaticinherited

get information about the parameters, that are used in loadParameters() and saveParameters().

The Infos are appended to the passed array

Parameters
parray 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().

◆ setProgressReporter()

template<typename KF >
void svt::SVMBase< KF >::setProgressReporter ( ProgressReporter pr)
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.

Parameters
prpointer 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.

Field Documentation

◆ p_kernel

template<typename KF >
KF svt::SVMBase< KF >::p_kernel
protectedinherited

◆ _terminationEpsilon

template<typename KF >
double svt::SVMBase< KF >::_terminationEpsilon
protectedinherited

◆ _cacheSizeMB

template<typename KF >
float svt::SVMBase< KF >::_cacheSizeMB
protectedinherited

◆ _shrinkingFlag

template<typename KF >
bool svt::SVMBase< KF >::_shrinkingFlag
protectedinherited

◆ _pr

template<typename KF >
ProgressReporter* svt::SVMBase< KF >::_pr
protectedinherited

The documentation for this class was generated from the following file: