iRoCS Toolbox
1.1.0
|
#include <BasicSVMAdapter.hh>
Public Member Functions | |
BasicSVMAdapter () | |
virtual | ~BasicSVMAdapter () |
virtual double | classify (const FV &testObject)=0 |
classify the given Feature Vector. More... | |
virtual double | classIndexToLabel (unsigned int classIndex) const =0 |
map classIndex to label (loadModel() or train() must have been called before) More... | |
virtual void | clearKernelCache ()=0 |
call clearCache() method of selected kernel, e.g., for Kernel_MATRIX this will clear the internal cache matrix. More... | |
virtual void | computeTrainKernelMatrix (float **kmatrix, const std::vector< FV > &featureVectors)=0 |
Evaluate kernel matrix of the svm. More... | |
bool | getStoreClassificationDetailsFlag () const |
virtual FV * | getSupportVector (int i) const =0 |
returns ith SV in model More... | |
virtual std::vector< const typename svt::Model< FV > *> | getTwoClassModels () const =0 |
returns vector containing pointers to all TwoClassModels More... | |
virtual std::vector< typename svt::Model< FV > *> | getTwoClassModels ()=0 |
virtual void | loadModel (STDATA &stData)=0 |
load model data from stData into SVM's. More... | |
virtual void | loadParameters (STDATA &stData)=0 |
Read all parameters (e.g. More... | |
virtual void | loadParameters (StDataASCII &stData)=0 |
virtual void | loadParameters (StDataCmdLine &stData)=0 |
Same as loadParameters, but for Parameters from command line. More... | |
virtual int | nClasses () const =0 |
get number of Classes (loadModel() or train() must have been called before) More... | |
virtual size_t | nSupportVectors () const =0 |
returns number of SV in model More... | |
virtual void | optimizeLinearModel ()=0 |
optimize model for faster classification More... | |
virtual void | saveClassificationDetailsASCII (StDataASCII &stData) const =0 |
classify the given Feature Vector. More... | |
virtual void | saveModel (STDATA &stData) const =0 |
save resulting model from training process into given map More... | |
virtual void | saveOnlyKernelParameters (StDataASCII &stData) const =0 |
save only Kernel Parameters (this is used for user information and to detect in grid search, wether a kernel parameter is changed More... | |
virtual void | saveParameters (STDATA &stData) const =0 |
store all parameters of the SVM to given map More... | |
virtual void | saveParameters (StDataASCII &stData) const =0 |
same as saveParameters(), but with fixed StDataASCII class independent from given STDATA template parameter. More... | |
virtual void | saveTrainingInfos (STDATA &stData, int detailLevel=1)=0 |
save additional trainnig infos to given structured data More... | |
virtual void | saveTrainingInfos (StDataASCII &stData, int detailLevel=1)=0 |
same as saveTrainingInfos(), but with fixed StDataASCII class independent from given STDATA template parameter. More... | |
virtual void | setProgressReporter (ProgressReporter *pr)=0 |
set progress reporter object. More... | |
void | setStoreClassificationDetailsFlag (bool f) |
virtual void | train (const GroupedTrainingData< FV > &trainData)=0 |
train SVM with given training data. More... | |
virtual void | train (const SVM_Problem< FV > &problem)=0 |
train SVM with given Feature Vectors. More... | |
template<typename ForwardIter > | |
void | train (ForwardIter FV_begin, const ForwardIter &FV_end) |
train the Multi Class SVM with the given feature vectors. More... | |
template<typename ForwardIter , typename Accessor > | |
void | train (ForwardIter FV_begin, const ForwardIter &FV_end, Accessor accessor) |
same as train(), but you can specify an Accessor for accessing the elements of your container. More... | |
virtual void | updateKernelCache (const GroupedTrainingData< FV > &trainData)=0 |
call updateCache() of selected kernel, e.g., for Kernel_MATRIX this will setup the internal cache matrix. More... | |
virtual void | updateKernelCache (const SVM_Problem< FV > &problem)=0 |
same as previous updateKernelCache() method, just for feature vectors that are stored within an SVM_Problem object Before calling, please ensure that your feature vectors have correct uniqueId()'s More... | |
virtual void | updateTestKernelCache (typename std::vector< FV >::iterator FV_begin, const typename std::vector< FV >::iterator &FV_end)=0 |
Load Test Kernel Cache. More... | |
Protected Attributes | |
bool | _storeClassificationDetailsFlag |
Definition at line 120 of file BasicSVMAdapter.hh.
|
inline |
Definition at line 124 of file BasicSVMAdapter.hh.
|
inlinevirtual |
Definition at line 129 of file BasicSVMAdapter.hh.
|
pure virtual |
set progress reporter object.
0 means no progress reporting. You are still the owner of this object, so you are responsible, that it exists during further calls to train(), etc. and that it is deleted afterwards
pr | pointer to ProgressReporter object or 0 if no progress reposting is desired |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
Read all parameters (e.g.
cost, gamma, etc) for the SVM from given structured data (e.g. an StDataASCII object). For non-existing keys the parameters remain unchanged, e.g. if key "cost" does not exist in the given map, the cost of the TwoClassSVMc will not be changed
stData | structured data containing parameters as key/value pairs |
. | depending on your STDATA class |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
|
pure virtual |
Same as loadParameters, but for Parameters from command line.
The StDataCmdLine keeps track of unused parameters
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
|
pure virtual |
load model data from stData into SVM's.
See documentation of this method in inherited classes for details.
stData | structured data containing parameters as key/value pairs |
. | depending on your STDATA class |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
store all parameters of the SVM to given map
stData | (output) structured data containing parameters as key/value pairs |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
same as saveParameters(), but with fixed StDataASCII class independent from given STDATA template parameter.
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
|
pure virtual |
save only Kernel Parameters (this is used for user information and to detect in grid search, wether a kernel parameter is changed
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
save resulting model from training process into given map
stData | (output) structured data containing parameters as key/value pairs |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
save additional trainnig infos to given structured data
stData | (output) structured data containing parameters as key/value pairs |
detailLevel | 0: nothing, 1: only statistics, 2: training infos from all two-class trainings. Default 1 |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
same as saveTrainingInfos(), but with fixed StDataASCII class independent from given STDATA template parameter.
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
|
pure virtual |
call updateCache() of selected kernel, e.g., for Kernel_MATRIX this will setup the internal cache matrix.
For pure Kernel_LINEAR or similar, this is an empty operation, so you can call it for every Kernel without negative effects. Before calling, please ensure that your feature vectors have correct uniqueId()'s
trainData | Structure with pointers to feature-vectors |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
same as previous updateKernelCache() method, just for feature vectors that are stored within an SVM_Problem object Before calling, please ensure that your feature vectors have correct uniqueId()'s
problem | Structure with pointers to feature-vectors |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
|
pure virtual |
FV_begin | begin of test-feature-vectors. |
FV_end | end of test-feature-vectors. |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
train SVM with given training data.
(multi class interface) this is the basic method, all others will call this one. The The resulting model is stored internally and can be accessd via saveModel(), or used for classify()
trainData | Structure with pointers to feature-vectors sorted by classes, the class start indizes and a classIndexToLabel translastion table |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::train(), and svt::BasicSVMAdapter< FV, STDATA >::~BasicSVMAdapter().
|
pure virtual |
train SVM with given Feature Vectors.
(general SVM interface – may also be used for one-class problems in future)
problem | Structure with pointers to feature-vectors and y's |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
|
inline |
train the Multi Class SVM with the given feature vectors.
The FeatureVector-Container must contain the Feature vectors directly, e.g., std::vector<MyFeatureVec>.
FV_begin | iterator to the first element of your FeatureVector-Container |
FV_end | iterator to one past the last element of your FeatureVector-Container |
Definition at line 344 of file BasicSVMAdapter.hh.
|
inline |
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*>
FVP_begin | iterator to the first element of your PointerToFeatureVector-Container |
FVP_end | iterator to one past the last element of your PointerToFeatureVector-Container |
accessor | functor, which accesses the feature vector in the container |
Definition at line 367 of file BasicSVMAdapter.hh.
|
pure virtual |
call clearCache() method of selected kernel, e.g., for Kernel_MATRIX this will clear the internal cache matrix.
You should call this method if you used updateCache() before training and now want to use the SVM for the classification of vectors, that are not within the training data.
ATTENTION: If you don't clear the Cache before classification with a kernel like Kernel_MATRIX or Kernel_SCALE, only the uniqueID() of the feature vectors will be used
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::train().
|
inline |
Definition at line 393 of file BasicSVMAdapter.hh.
|
inline |
Definition at line 398 of file BasicSVMAdapter.hh.
|
pure virtual |
classify the given Feature Vector.
testObject | test object. |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
pure virtual |
classify the given Feature Vector.
testObject | test object. | |
[out] | detailedResultsVec | vector with detailed results (results of all two class classifications) |
save classification details. Here the ordered labeles as "labels" and the according decision values as "dec_values". For this to work you must have called setStoreClassificationDetailsFlag( true) before classify()
resultVector | results from the classification |
stData | structured data, where to store the details |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
pure virtual |
Evaluate kernel matrix of the svm.
A square matrix is generated with the current 2-class-svm-kernel. Assumption: memory is already allocated for kmatrix.
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
pure virtual |
get number of Classes (loadModel() or train() must have been called before)
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
pure virtual |
map classIndex to label (loadModel() or train() must have been called before)
classIndex | the index of the class (when sorted by labels) |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
pure virtual |
returns number of SV in model
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
pure virtual |
returns ith SV in model
i | the index of the SV |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
pure virtual |
returns vector containing pointers to all TwoClassModels
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
pure virtual |
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
|
pure virtual |
optimize model for faster classification
Implemented in svt::BasicSVMAdapterTempl< FV, STDATA, MCSVMTYPE >.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag().
|
protected |
Definition at line 517 of file BasicSVMAdapter.hh.
Referenced by svt::BasicSVMAdapter< FV, STDATA >::getStoreClassificationDetailsFlag(), and svt::BasicSVMAdapter< FV, STDATA >::setStoreClassificationDetailsFlag().