iRoCS Toolbox  1.1.0
Data Structures | Public Types | Public Member Functions | Static Public Member Functions
svt::MultiClassSVMOneVsOne< SVM > Class Template Reference

The MultiClassSVMOneVsOne class provides a one vs. More...

#include <MultiClassSVMOneVsOne.hh>

Collaboration diagram for svt::MultiClassSVMOneVsOne< SVM >:

Data Structures

class  DummyResultMatrix
 
struct  Traits
 

Public Types

typedef TriangularMatrix< double > DetailedResultType
 

Public Member Functions

 MultiClassSVMOneVsOne (const SVM &svm)
 Create a multi class SVM basing on the given svm object. More...
 
 MultiClassSVMOneVsOne ()
 Create a multi class SVM. More...
 
template<typename FV , typename ResultMatrix >
double classify (const FV &testObject, const typename Traits< FV >::ModelType &model, ResultMatrix &resultMatrix) const
 classify the given testObject using the models in Model matrix. More...
 
template<typename FV >
double classify (const FV &testObject, const typename Traits< FV >::ModelType &model) const
 classify the given testObject using the model More...
 
void clearKernelCache () const
 call the clearKernelCache() method of selected two-class svm More...
 
template<typename STDATA >
void loadParameters (STDATA &stData)
 
template<typename FV , typename ResultMatrix >
unsigned int predictClassIndex (const FV &testObject, const typename Traits< FV >::ModelType &model, ResultMatrix &resultMatrix) const
 classify the given testObject using the model More...
 
template<typename FV >
unsigned int predictClassIndex (const FV &testObject, const typename Traits< FV >::ModelType &model) const
 classify the given testObject using the model More...
 
template<typename FV >
void retrainWithLeftOutVectors (const GroupedTrainingData< FV > &trainData, const typename Traits< FV >::ModelType &fullModel, const std::vector< char > &leaveOutFlagsByUID, typename Traits< FV >::ModelType &resultingModel) const
 calls the retrainWithLeftOutVectors() for each two-class model, only if the model is affected by the left out vectors More...
 
template<typename ModelType , typename STDATA >
void saveClassificationDetails (const ModelType &, const DetailedResultType &, STDATA &) const
 save classification details. More...
 
template<typename STDATA >
void saveParameters (STDATA &stData) const
 
void setProgressReporter (ProgressReporter *pr)
 set a progress reporter object. More...
 
template<typename FV >
void train (const GroupedTrainingData< FV > &trainData, typename Traits< FV >::ModelType &model) const
 train SVM with given Feature Vectors. More...
 
template<typename FV >
void train (const SVM_Problem< FV > &problem, typename Traits< FV >::ModelType &model) const
 train SVM with given Feature Vectors. More...
 
template<typename ForwardIter >
void train (ForwardIter FV_begin, const ForwardIter &FV_end, typename Traits< typename std::iterator_traits< ForwardIter >::value_type >::ModelType &model) const
 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, typename Traits< typename Accessor::template Traits< ForwardIter >::value_type >::ModelType &model, Accessor accessor) const
 same as train(), but you can specify an Accessor for accessing the elements of your container. More...
 
const SVM & twoClassSVM () const
 
SVM & twoClassSVM ()
 
template<typename ForwardIter , typename Accessor >
void updateKernelCache (const ForwardIter &fvBegin, const ForwardIter &fvEnd, Accessor accessor) const
 call the updateKernelCache() method of selected two-class svm More...
 

Static Public Member Functions

static const char * description ()
 
static void getParamInfos (std::vector< ParamInfo > &)
 get information about the parameters, that are used in loadParameters() and saveParameters(). More...
 
static const char * name ()
 

Detailed Description

template<typename SVM>
class svt::MultiClassSVMOneVsOne< SVM >

The MultiClassSVMOneVsOne class provides a one vs.

one multi class algorithm.

Create a multi class SVM basing on the given "two-class-SVM", using the One versus One algorithm.

Definition at line 169 of file MultiClassSVMOneVsOne.hh.

Member Typedef Documentation

◆ DetailedResultType

template<typename SVM >
typedef TriangularMatrix<double> svt::MultiClassSVMOneVsOne< SVM >::DetailedResultType

Definition at line 184 of file MultiClassSVMOneVsOne.hh.

Constructor & Destructor Documentation

◆ MultiClassSVMOneVsOne() [1/2]

template<typename SVM >
svt::MultiClassSVMOneVsOne< SVM >::MultiClassSVMOneVsOne ( const SVM &  svm)
inline

Create a multi class SVM basing on the given svm object.

Parameters
svmTwo-Class Support vector maschine, the object is copied to internal variable

Definition at line 213 of file MultiClassSVMOneVsOne.hh.

◆ MultiClassSVMOneVsOne() [2/2]

template<typename SVM >
svt::MultiClassSVMOneVsOne< SVM >::MultiClassSVMOneVsOne ( )
inline

Create a multi class SVM.

with Default Constructot of template Parameter SVM

Definition at line 227 of file MultiClassSVMOneVsOne.hh.

Member Function Documentation

◆ setProgressReporter()

template<typename SVM >
void svt::MultiClassSVMOneVsOne< SVM >::setProgressReporter ( ProgressReporter pr)
inline

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 247 of file MultiClassSVMOneVsOne.hh.

◆ twoClassSVM() [1/2]

template<typename SVM >
const SVM& svt::MultiClassSVMOneVsOne< SVM >::twoClassSVM ( ) const
inline
Returns
const reference to internal two-class SVM

Definition at line 260 of file MultiClassSVMOneVsOne.hh.

◆ twoClassSVM() [2/2]

template<typename SVM >
SVM& svt::MultiClassSVMOneVsOne< SVM >::twoClassSVM ( )
inline
Returns
nonconst reference to internal two-class SVM

Definition at line 270 of file MultiClassSVMOneVsOne.hh.

◆ updateKernelCache()

template<typename SVM >
template<typename ForwardIter , typename Accessor >
void svt::MultiClassSVMOneVsOne< SVM >::updateKernelCache ( const ForwardIter &  fvBegin,
const ForwardIter &  fvEnd,
Accessor  accessor 
) const
inline

call the updateKernelCache() method of selected two-class svm

Parameters

Definition at line 288 of file MultiClassSVMOneVsOne.hh.

◆ clearKernelCache()

template<typename SVM >
void svt::MultiClassSVMOneVsOne< SVM >::clearKernelCache ( ) const
inline

call the clearKernelCache() method of selected two-class svm

Parameters

Definition at line 307 of file MultiClassSVMOneVsOne.hh.

◆ train() [1/4]

template<typename SVM >
template<typename FV >
void svt::MultiClassSVMOneVsOne< SVM >::train ( const GroupedTrainingData< FV > &  trainData,
typename Traits< FV >::ModelType &  model 
) const

train SVM with given Feature Vectors.

(raw interface)

this is the basic method, all others will call this one

Parameters
trainDataStructure with pointers to feature-vectors
model(output) model containing a triangular matrix of trained of TwoClassModels. It stores only pointers to the feature vectors, but you still own them!

Template Parameters:

  • FV feature vector class. Must fulfill the interfaces
    • svt_check::RequireFeatureVectorUniqueID< FV >
    • svt_check::RequireMinimalTCModel< SVM::Traits<FV>::ModelType >
    • svt_check::RequireSVMKernelUpdateCache< SVM, FV>
    • svt_check::RequireSVMBasicTraining< SVM, FV>

Definition at line 109 of file MultiClassSVMOneVsOne.hh.

Referenced by svt::MultiClassSVMOneVsOne< SVM >::clearKernelCache(), and svt::MultiClassSVMOneVsOne< SVM >::train().

◆ train() [2/4]

template<typename SVM >
template<typename FV >
void svt::MultiClassSVMOneVsOne< SVM >::train ( const SVM_Problem< FV > &  problem,
typename Traits< FV >::ModelType &  model 
) const
inline

train SVM with given Feature Vectors.

(general SVM interface)

Parameters
problemStructure with pointers to feature-vectors and y's
model(output) model containing a triangular matrix of trained of TwoClassModels. It stores only pointers to the feature vectors, but you still own them!

Definition at line 352 of file MultiClassSVMOneVsOne.hh.

◆ train() [3/4]

template<typename SVM >
template<typename ForwardIter >
void svt::MultiClassSVMOneVsOne< SVM >::train ( ForwardIter  FV_begin,
const ForwardIter &  FV_end,
typename Traits< typename std::iterator_traits< ForwardIter >::value_type >::ModelType &  model 
) const
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>.

Parameters
FV_beginiterator to the first element of your FeatureVector-Container
FV_enditerator to one past the last element of your FeatureVector-Container
model(output) model containing a triangular matrix of trained of TwoClassModels. It stores only pointers to the feature vectors, but you still own them!
Exceptions

Definition at line 383 of file MultiClassSVMOneVsOne.hh.

◆ train() [4/4]

template<typename SVM >
template<typename ForwardIter , typename Accessor >
void svt::MultiClassSVMOneVsOne< SVM >::train ( ForwardIter  FV_begin,
const ForwardIter &  FV_end,
typename Traits< typename Accessor::template Traits< ForwardIter >::value_type >::ModelType &  model,
Accessor  accessor 
) const
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*>

Parameters
FVP_beginiterator to the first element of your PointerToFeatureVector-Container
FVP_enditerator to one past the last element of your PointerToFeatureVector-Container
model(output) model containing a triangular matrix of trained of TwoClassModels. It stores only pointers to the feature vectors, but you still own them!
accessorfunctor, which accesses the feature vector in the container
Exceptions

Definition at line 415 of file MultiClassSVMOneVsOne.hh.

◆ retrainWithLeftOutVectors()

template<typename SVM >
template<typename FV >
void svt::MultiClassSVMOneVsOne< SVM >::retrainWithLeftOutVectors ( const GroupedTrainingData< FV > &  trainData,
const typename Traits< FV >::ModelType &  fullModel,
const std::vector< char > &  leaveOutFlagsByUID,
typename Traits< FV >::ModelType &  resultingModel 
) const

calls the retrainWithLeftOutVectors() for each two-class model, only if the model is affected by the left out vectors

Parameters
trainDataStructure with pointers to feature-vectors must be identical to training data set that was used to train the fullModel
fullModelmodel that was trained using complete training data set without leaving out anything
leaveOutFlagsByUIDleave out flag for each feature vector, accessed via its uniqueID (true means leave this vector out from training)
resultingModel(output) model containing a triangular matrix of trained of TwoClassModels. It stores only pointers to the feature vectors, but you still own them!

Definition at line 242 of file MultiClassSVMOneVsOne.hh.

Referenced by svt::MultiClassSVMOneVsOne< SVM >::train().

◆ predictClassIndex() [1/2]

template<typename SVM >
template<typename FV , typename ResultMatrix >
unsigned int svt::MultiClassSVMOneVsOne< SVM >::predictClassIndex ( const FV &  testObject,
const typename Traits< FV >::ModelType &  model,
ResultMatrix &  resultMatrix 
) const

classify the given testObject using the model

Parameters
testObjectthe test object
modelthe model
[out]resultMatrixresults (decision values) from the two-class classifications. resultMatrix (should be TriangularMatrix<double>) will be resized properly
Returns
classIndex of winning class

Definition at line 433 of file MultiClassSVMOneVsOne.hh.

Referenced by svt::MultiClassSVMOneVsOne< SVM >::classify(), svt::MultiClassSVMOneVsOne< SVM >::predictClassIndex(), and svt::MultiClassSVMOneVsOne< SVM >::train().

◆ predictClassIndex() [2/2]

template<typename SVM >
template<typename FV >
unsigned int svt::MultiClassSVMOneVsOne< SVM >::predictClassIndex ( const FV &  testObject,
const typename Traits< FV >::ModelType &  model 
) const
inline

classify the given testObject using the model

Parameters
testObjectthe test object
modelthe model
Returns
classIndex of winning class

Definition at line 490 of file MultiClassSVMOneVsOne.hh.

◆ classify() [1/2]

template<typename SVM >
template<typename FV , typename ResultMatrix >
double svt::MultiClassSVMOneVsOne< SVM >::classify ( const FV &  testObject,
const typename Traits< FV >::ModelType &  model,
ResultMatrix &  resultMatrix 
) const
inline

classify the given testObject using the models in Model matrix.

Parameters
testObjectthe test object
modelthe model
[out]resultMatrixresults (decision values) from the two-class classifications. resultMatrix will be resized properly. The type could be the typedef'ed DetailedResultType or your own matrix class.
Returns
label of winning class

Definition at line 515 of file MultiClassSVMOneVsOne.hh.

Referenced by svt::MultiClassSVMOneVsOne< SVM >::classify().

◆ classify() [2/2]

template<typename SVM >
template<typename FV >
double svt::MultiClassSVMOneVsOne< SVM >::classify ( const FV &  testObject,
const typename Traits< FV >::ModelType &  model 
) const
inline

classify the given testObject using the model

Parameters
testObjectthe test object
modelthe model
Returns
label of winning class

Definition at line 535 of file MultiClassSVMOneVsOne.hh.

◆ loadParameters()

template<typename SVM >
template<typename STDATA >
void svt::MultiClassSVMOneVsOne< SVM >::loadParameters ( STDATA &  stData)
inline

Definition at line 544 of file MultiClassSVMOneVsOne.hh.

◆ saveParameters()

template<typename SVM >
template<typename STDATA >
void svt::MultiClassSVMOneVsOne< SVM >::saveParameters ( STDATA &  stData) const
inline

Definition at line 553 of file MultiClassSVMOneVsOne.hh.

◆ saveClassificationDetails()

template<typename SVM >
template<typename ModelType , typename STDATA >
void svt::MultiClassSVMOneVsOne< SVM >::saveClassificationDetails ( const ModelType &  ,
const DetailedResultType ,
STDATA &   
) const
inline

save classification details.

Here the ordered lables as "labels" and the according decision values as "dec_values"

Parameters
modelthe used model
resulMatrixresults from the classification
stDatastructured data, where to store the details

Definition at line 572 of file MultiClassSVMOneVsOne.hh.

◆ getParamInfos()

template<typename SVM >
static void svt::MultiClassSVMOneVsOne< SVM >::getParamInfos ( std::vector< ParamInfo > &  )
inlinestatic

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 590 of file MultiClassSVMOneVsOne.hh.

◆ name()

template<typename SVM >
static const char* svt::MultiClassSVMOneVsOne< SVM >::name ( )
inlinestatic

◆ description()

template<typename SVM >
static const char* svt::MultiClassSVMOneVsOne< SVM >::description ( )
inlinestatic

Definition at line 600 of file MultiClassSVMOneVsOne.hh.


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