iRoCS Toolbox
1.1.0
|
The TwoClassSVMc class (is/provides/specifies/contains) More...
#include <TwoClassSVMc.hh>
Data Structures | |
struct | Traits |
Public Types | |
typedef KF | KF_type |
Public Member Functions | |
TwoClassSVMc () | |
(description) More... | |
TwoClassSVMc (const KF &kernel) | |
(description) More... | |
~TwoClassSVMc () | |
(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... | |
double | cost () const |
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 and save parameters cost and weight from map. More... | |
template<typename STDATA > | |
void | saveParameters (STDATA &stData) const |
void | setCacheSizeMB (float s) |
set cache memory size in MB (default: 40) More... | |
void | setCost (double c) |
set the parameter C for C-SVM (cost for outliers). 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... | |
void | setWeightOfPositiveClass (double weight) |
set the parameter C of positive class (labeled with +1) to weight*C. More... | |
bool | shrinkingFlag () const |
double | terminationEpsilon () const |
template<typename FV > | |
void | train (const SVM_Problem< FV > &problem, Model< FV > &model) const |
train SVM with given Feature Vectors. More... | |
template<typename ForwardIter > | |
void | train (ForwardIter FV_begin, const ForwardIter &FV_end, svt::Model< typename std::iterator_traits< ForwardIter >::value_type > &model) const |
train (STL-like interface) Your feature vector class must provide a method double getLabel(), which returns +1 or -1. More... | |
template<typename ForwardIter , typename Accessor > | |
void | train (ForwardIter FV_begin, const ForwardIter &FV_end, svt::Model< typename Accessor::template Traits< ForwardIter >::value_type > &model, Accessor accessor) const |
train (STL-like interface with additional Accessor) More... | |
template<typename ForwardIter , typename Accessor > | |
void | updateKernelCache (const ForwardIter &fvBegin, const ForwardIter &fvEnd, Accessor accessor) const |
call the updateCache() method of selected Kernel More... | |
double | weightOfPositiveClass () const |
Static Public Member Functions | |
static const char * | description () |
static void | getParamInfos (std::vector< ParamInfo > &p) |
get information about the parameters, that are used in loadParameters() and saveParameters(). More... | |
static const char * | name () |
Protected Member Functions | |
template<typename FV > | |
void | solve_c_svc (const SVM_Problem< FV > *prob, double *alpha, SolutionInfo *si, Model< FV > &model) const |
Protected Attributes | |
float | _cacheSizeMB |
ProgressReporter * | _pr |
bool | _shrinkingFlag |
double | _terminationEpsilon |
KF | p_kernel |
The TwoClassSVMc class (is/provides/specifies/contains)
(description)
Definition at line 132 of file TwoClassSVMc.hh.
|
inherited |
Definition at line 137 of file TwoClassSVM.hh.
|
inline |
(description)
Definition at line 148 of file TwoClassSVMc.hh.
|
inline |
|
inline |
(description)
Definition at line 175 of file TwoClassSVMc.hh.
void svt::TwoClassSVMc< KF >::train | ( | const SVM_Problem< FV > & | problem, |
Model< FV > & | model | ||
) | const |
train SVM with given Feature Vectors.
(raw interface)
this is the basic method, all others will call this one
problem | Structure with pointers to feature-vectors |
model | (output) model containing pointers to feature vectors, that became support vectors, alphas and rho |
Referenced by svt::TwoClassSVMc< KF >::train(), and svt::TwoClassSVMc< KF >::~TwoClassSVMc().
|
inline |
train (STL-like interface) Your feature vector class must provide a method double getLabel(), which returns +1 or -1.
The ModelType is svt::Model<FV>. Positive and negative labled feature vectors may be in any order in the given Container.
FV_begin | iterator pointing to first element of the container with the feature vectors |
FV_end | iterator pointing one past the last element of the container with the feature vectors |
model | (output) model containing pointers to feature vectors, that became support vectors, alphas and rho |
Definition at line 214 of file TwoClassSVMc.hh.
void svt::TwoClassSVMc< KF >::train | ( | ForwardIter | FV_begin, |
const ForwardIter & | FV_end, | ||
svt::Model< typename Accessor::template Traits< ForwardIter >::value_type > & | model, | ||
Accessor | accessor | ||
) | const |
train (STL-like interface with additional Accessor)
same as train(), but you can specify an Accessor for accessing the elements of your container. This accessor must return a reference to the corresponding feature vector. Use DirectAccessor for containers like std::vector<FV> and DereferencingAccessor for containers like std::vector<FV*>
FV_begin | iterator pointing to first element of the container with the feature vectors |
FV_end | iterator pointing one past the last element of the container with the feature vectors |
model | (output) model containing pointers to feature vectors, that became support vectors, alphas and rho |
accessor | functor, which converts an iterator of your container into a pointer to a feature vector |
|
inline |
set the parameter C for C-SVM (cost for outliers).
Default: 1.0
c | parameter C |
Definition at line 259 of file TwoClassSVMc.hh.
|
inline |
Definition at line 264 of file TwoClassSVMc.hh.
|
inline |
set the parameter C of positive class (labeled with +1) to weight*C.
Default: 1.0
weight | new weight |
Definition at line 279 of file TwoClassSVMc.hh.
|
inline |
Definition at line 284 of file TwoClassSVMc.hh.
|
inline |
Load and save parameters cost and weight from map.
Definition at line 296 of file TwoClassSVMc.hh.
|
inline |
Definition at line 306 of file TwoClassSVMc.hh.
|
inlinestatic |
Definition at line 316 of file TwoClassSVMc.hh.
Referenced by svt::TwoClassSVMc< KF >::saveParameters().
|
inlinestatic |
Definition at line 321 of file TwoClassSVMc.hh.
|
inlinestatic |
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 336 of file TwoClassSVMc.hh.
|
protected |
Referenced by svt::TwoClassSVMc< KF >::getParamInfos().
|
inherited |
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().
|
inherited |
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().
|
inherited |
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().
|
inherited |
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 |
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().