iRoCS Toolbox
1.1.0
|
The MultiClassSVMOneVsRest class provides a one vs. More...
#include <MultiClassSVMOneVsRest.hh>
Data Structures | |
struct | DecisionValueAndLabel |
class | DummyResultVector |
struct | Traits |
Public Types | |
typedef std::vector< double > | DetailedResultType |
Public Member Functions | |
MultiClassSVMOneVsRest (const SVM &svm) | |
Create a multi class SVM basing on the given "two-class-SVM", using the One versus Rest algorithm. More... | |
MultiClassSVMOneVsRest () | |
template<typename FV , typename ResultVector > | |
double | classify (const FV &testObject, const typename Traits< FV >::ModelType &model, ResultVector &resultVector) const |
classify the given testObject using the model 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 ResultVector > | |
unsigned int | predictClassIndex (const FV &testObject, const typename Traits< FV >::ModelType &model, ResultVector &resultVector) 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 &model, const DetailedResultType &resultVector, STDATA &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 |
(description) More... | |
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 () |
The MultiClassSVMOneVsRest class provides a one vs.
rest multi class algorithm
SVM | a two-class-svm |
Definition at line 140 of file MultiClassSVMOneVsRest.hh.
typedef std::vector<double> svt::MultiClassSVMOneVsRest< SVM >::DetailedResultType |
Definition at line 152 of file MultiClassSVMOneVsRest.hh.
|
inline |
Create a multi class SVM basing on the given "two-class-SVM", using the One versus Rest algorithm.
The two class SVM may be either one of svt::TwoClassSVMc, or svt::TwoClassSVMnu or your own SVM implementation, which fulfills the following interface: SVM::train( ITER fvs_begin, ITER fvs_end, MODEL& model); ...
svm | Two-Class Support vector maschine |
Definition at line 206 of file MultiClassSVMOneVsRest.hh.
|
inline |
Definition at line 213 of file MultiClassSVMOneVsRest.hh.
|
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.
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 232 of file MultiClassSVMOneVsRest.hh.
|
inline |
|
inline |
Definition at line 256 of file MultiClassSVMOneVsRest.hh.
|
inline |
call the updateKernelCache() method of selected two-class svm
Definition at line 274 of file MultiClassSVMOneVsRest.hh.
|
inline |
call the clearKernelCache() method of selected two-class svm
Definition at line 293 of file MultiClassSVMOneVsRest.hh.
void svt::MultiClassSVMOneVsRest< 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
trainData | Structure with pointers to feature-vectors |
model | (output) model containing a vector of trained of TwoClassModels. It stores only pointers to the feature vectors, but you still own them! |
Definition at line 96 of file MultiClassSVMOneVsRest.hh.
Referenced by svt::MultiClassSVMOneVsRest< SVM >::clearKernelCache(), and svt::MultiClassSVMOneVsRest< SVM >::train().
|
inline |
train SVM with given Feature Vectors.
(general SVM interface)
problem | Structure 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 328 of file MultiClassSVMOneVsRest.hh.
|
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 |
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 355 of file MultiClassSVMOneVsRest.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 |
model | (output) model containing a triangular matrix of trained of TwoClassModels. It stores only pointers to the feature vectors, but you still own them! |
accessor | functor, which accesses the feature vector in the container |
Definition at line 386 of file MultiClassSVMOneVsRest.hh.
void svt::MultiClassSVMOneVsRest< 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
trainData | Structure with pointers to feature-vectors must be identical to training data set that was used to train the fullModel |
fullModel | model that was trained using complete training data set without leaving out anything |
leaveOutFlagsByUID | leave 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 220 of file MultiClassSVMOneVsRest.hh.
Referenced by svt::MultiClassSVMOneVsRest< SVM >::train().
unsigned int svt::MultiClassSVMOneVsRest< SVM >::predictClassIndex | ( | const FV & | testObject, |
const typename Traits< FV >::ModelType & | model, | ||
ResultVector & | resultVector | ||
) | const |
classify the given testObject using the model
testObject | the test object | |
model | the model | |
[out] | resultVector | results (decision values) from the two-class classifications. resultVector will be resized properly. The type could be the typedef'ed DetailedResultType or your own resultVector class. |
Definition at line 407 of file MultiClassSVMOneVsRest.hh.
Referenced by svt::MultiClassSVMOneVsRest< SVM >::classify(), svt::MultiClassSVMOneVsRest< SVM >::predictClassIndex(), and svt::MultiClassSVMOneVsRest< SVM >::train().
|
inline |
classify the given testObject using the model
testObject | the test object |
model | the model |
Definition at line 458 of file MultiClassSVMOneVsRest.hh.
|
inline |
classify the given testObject using the model
testObject | the test object | |
model | the model | |
[out] | resultVector | results (decision values) from the two-class classifications. resultVector will be resized properly. The type could be the typedef'ed DetailedResultType or your own resultVector class. |
Definition at line 482 of file MultiClassSVMOneVsRest.hh.
Referenced by svt::MultiClassSVMOneVsRest< SVM >::classify().
|
inline |
classify the given testObject using the model
testObject | the test object |
model | the model |
Definition at line 501 of file MultiClassSVMOneVsRest.hh.
|
inline |
Definition at line 510 of file MultiClassSVMOneVsRest.hh.
|
inline |
Definition at line 517 of file MultiClassSVMOneVsRest.hh.
|
inline |
save classification details.
Here the ordered labels as "labels" and the according decision values as "dec_values"
model | the used model |
resultVector | results from the classification |
stData | structured data, where to store the details |
Definition at line 536 of file MultiClassSVMOneVsRest.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 580 of file MultiClassSVMOneVsRest.hh.
|
inlinestatic |
Definition at line 584 of file MultiClassSVMOneVsRest.hh.
Referenced by svt::MultiClassSVMOneVsRest< SVM >::saveParameters().
|
inlinestatic |
Definition at line 589 of file MultiClassSVMOneVsRest.hh.