98 #ifndef MULTICLASSSVMONEVSREST_HH 99 #define MULTICLASSSVMONEVSREST_HH 139 template<
typename SVM>
146 template<
typename FV>
235 _twoClassSVM.setProgressReporter( pr);
273 template<
typename ForwardIter,
typename Accessor>
275 const ForwardIter& fvEnd,
276 Accessor accessor)
const 278 _twoClassSVM.updateKernelCache( fvBegin, fvEnd, accessor);
295 _twoClassSVM.clearKernelCache();
311 template<
typename FV>
327 template<
typename FV>
332 train( trainData, model);
354 template<
typename ForwardIter>
356 const ForwardIter& FV_end,
357 typename Traits<
typename std::iterator_traits< ForwardIter>::value_type>::
ModelType& model)
const 385 template<
typename ForwardIter,
typename Accessor>
387 const ForwardIter& FV_end,
389 Accessor accessor)
const 394 train( trainData, model);
418 template<
typename FV>
422 const std::vector<char>& leaveOutFlagsByUID,
440 template<
typename FV,
typename ResultVector>
442 const FV& testObject,
444 ResultVector& resultVector)
const;
457 template<
typename FV>
459 const FV& testObject,
481 template<
typename FV,
typename ResultVector>
484 ResultVector& resultVector)
const 500 template<
typename FV>
505 return classify( testObject, model, dummy);
509 template<
typename STDATA>
513 _twoClassSVM.loadParameters( stData);
516 template<
typename STDATA>
520 stData.setValue(
"multi_class_type",
name());
521 _twoClassSVM.saveParameters( stData);
535 template<
typename ModelType,
typename STDATA>
537 const DetailedResultType& resultVector,
538 STDATA& stData)
const 541 std::vector< DecisionValueAndLabel >
542 decValueLabelList( resultVector.size());
545 for(
size_t i = 0; i < resultVector.size(); ++i)
547 decValueLabelList[i].decisionValue = resultVector[i];
548 decValueLabelList[i].label = model.classIndexToLabel(
549 static_cast<int>(i));
553 std::sort( decValueLabelList.begin(), decValueLabelList.end());
556 std::vector<double> decValueList( decValueLabelList.size());
557 std::vector<double> labelList( decValueLabelList.size());
558 for(
size_t i = 0; i < decValueLabelList.size(); ++i)
560 decValueList[i] = decValueLabelList[i].decisionValue;
561 labelList[i] = decValueLabelList[i].label;
564 stData.setArray(
"labels", labelList.begin(), labelList.size());
565 stData.setArray(
"dec_values",
566 decValueList.begin(), decValueList.size());
586 return "one_vs_rest";
591 return "multi-class SVM by using the One versus Rest approach";
600 #include "MultiClassSVMOneVsRest.icc" The GroupedTrainingData class is a container for feature vectors.
double classify(const FV &testObject, const typename Traits< FV >::ModelType &model, ResultVector &resultVector) const
classify the given testObject using the model
#define CHECK_MEMBER_TEMPLATE(c)
static void getParamInfos(std::vector< ParamInfo > &)
get information about the parameters, that are used in loadParameters() and saveParameters().
MultiClassSVMOneVsRest(const SVM &svm)
Create a multi class SVM basing on the given "two-class-SVM", using the One versus Rest algorithm...
void train(const GroupedTrainingData< FV > &trainData, typename Traits< FV >::ModelType &model) const
train SVM with given Feature Vectors.
void loadParameters(STDATA &stData)
double classIndexToLabel(unsigned int classIndex) const
unsigned int predictClassIndex(const FV &testObject, const typename Traits< FV >::ModelType &model) const
classify the given testObject using the model
#define CHECK_CLASS_TEMPLATE1(c)
void saveClassificationDetails(const ModelType &model, const DetailedResultType &resultVector, STDATA &stData) const
save classification details.
std::vector< double > DetailedResultType
#define CHECK_CLASS_TEMPLATE2(c)
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...
Ensure that TESTCLASS provides a loadParameters() and saveParamters() method.
double classify(const FV &testObject, const typename Traits< FV >::ModelType &model) const
classify the given testObject using the model
const SVM & twoClassSVM() const
(description)
unsigned int predictClassIndex(const FV &testObject, const typename Traits< FV >::ModelType &model, ResultVector &resultVector) const
classify the given testObject using the model
The MultiClassSVMOneVsRest class provides a one vs.
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 ...
void saveParameters(STDATA &stData) const
void train(const SVM_Problem< FV > &problem, typename Traits< FV >::ModelType &model) const
train SVM with given Feature Vectors.
static const char * description()
Model_MC_OneVsRest< typename SVM::template Traits< FV >::ModelType > ModelType
void updateKernelCache(const ForwardIter &fvBegin, const ForwardIter &fvEnd, Accessor accessor) const
call the updateKernelCache() method of selected two-class svm
bool operator<(const DecisionValueAndLabel &rhs) const
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.
Ensure that TESTCLASS provides a setProgressReporter() method.
static const char * name()
void resize(unsigned int)
void setProgressReporter(ProgressReporter *pr)
set a progress reporter object.
void clearKernelCache() const
call the clearKernelCache() method of selected two-class svm