|
@@ -51,92 +51,92 @@ namespace OBJREC {
|
|
|
|
|
|
class GenericClassifierSelection
|
|
|
{
|
|
|
- public:
|
|
|
+ public:
|
|
|
|
|
|
- static VecClassifier *selectVecClassifier ( const NICE::Config *conf, std::string classifier_type )
|
|
|
- {
|
|
|
- std::vector<std::string> submatches;
|
|
|
- VecClassifier *classifier = NULL;
|
|
|
+ static VecClassifier *selectVecClassifier ( const NICE::Config *conf, std::string classifier_type )
|
|
|
+ {
|
|
|
+ std::vector<std::string> submatches;
|
|
|
+ VecClassifier *classifier = NULL;
|
|
|
|
|
|
- if ( classifier_type == "amit" ) {
|
|
|
- classifier = new VCAmitSVM ( conf );
|
|
|
+ if ( classifier_type == "amit" ) {
|
|
|
+ classifier = new VCAmitSVM ( conf );
|
|
|
|
|
|
- } else if ( classifier_type == "nn" ) {
|
|
|
- classifier = new VCNearestNeighbour( conf, new NICE::EuclidianDistance<double>() );
|
|
|
-#ifdef NICE_USELIB_ICE
|
|
|
- } else if ( classifier_type == "gauss" ) {
|
|
|
- classifier = new VCSimpleGaussian( conf );
|
|
|
+ } else if ( classifier_type == "nn" ) {
|
|
|
+ classifier = new VCNearestNeighbour ( conf, new NICE::EuclidianDistance<double>() );
|
|
|
+#ifdef NICE_USELIB_ICE
|
|
|
+ } else if ( classifier_type == "gauss" ) {
|
|
|
+ classifier = new VCSimpleGaussian ( conf );
|
|
|
#endif
|
|
|
- } else if ( classifier_type == "random_forest" ) {
|
|
|
- FeaturePoolClassifier *fpc = new FPCRandomForests ( conf, "RandomForest" );
|
|
|
- classifier = new VCFeaturePool ( conf, fpc );
|
|
|
-
|
|
|
- } else if ( classifier_type == "sparse_logistic_regression" ) {
|
|
|
- FeaturePoolClassifier *fpc = new FPCSMLR ( conf, "SparseLogisticRegression" );
|
|
|
- classifier = new VCFeaturePool ( conf, fpc );
|
|
|
-
|
|
|
- } else if ( classifier_type == "boost" ) {
|
|
|
- FeaturePoolClassifier *fpc = new FPCBoosting ( conf, "Boost" );
|
|
|
- classifier = new VCFeaturePool ( conf, fpc );
|
|
|
-
|
|
|
- } else if ( classifier_type == "decision_tree" ) {
|
|
|
- FeaturePoolClassifier *fpc = new FPCDecisionTree ( conf, "DecisionTree" );
|
|
|
- classifier = new VCFeaturePool ( conf, fpc );
|
|
|
+ } else if ( classifier_type == "random_forest" ) {
|
|
|
+ FeaturePoolClassifier *fpc = new FPCRandomForests ( conf, "RandomForest" );
|
|
|
+ classifier = new VCFeaturePool ( conf, fpc );
|
|
|
+
|
|
|
+ } else if ( classifier_type == "sparse_logistic_regression" ) {
|
|
|
+ FeaturePoolClassifier *fpc = new FPCSMLR ( conf, "SparseLogisticRegression" );
|
|
|
+ classifier = new VCFeaturePool ( conf, fpc );
|
|
|
+
|
|
|
+ } else if ( classifier_type == "boost" ) {
|
|
|
+ FeaturePoolClassifier *fpc = new FPCBoosting ( conf, "Boost" );
|
|
|
+ classifier = new VCFeaturePool ( conf, fpc );
|
|
|
+
|
|
|
+ } else if ( classifier_type == "decision_tree" ) {
|
|
|
+ FeaturePoolClassifier *fpc = new FPCDecisionTree ( conf, "DecisionTree" );
|
|
|
+ classifier = new VCFeaturePool ( conf, fpc );
|
|
|
#ifdef NICE_USELIB_ICE
|
|
|
- } else if ( (classifier_type == "cross_generalization") || (classifier_type == "bart") ) {
|
|
|
- classifier = new VCCrossGeneralization ( conf );
|
|
|
+ } else if ( ( classifier_type == "cross_generalization" ) || ( classifier_type == "bart" ) ) {
|
|
|
+ classifier = new VCCrossGeneralization ( conf );
|
|
|
#endif
|
|
|
#ifdef NICE_USELIB_SVMLIGHT
|
|
|
- } else if ( (classifier_type == "svmlight") || (classifier_type == "svm") ) {
|
|
|
- classifier = new VCSVMLight ( conf );
|
|
|
- } else if ( (classifier_type == "svm_onevsone") ) {
|
|
|
- classifier = new VCOneVsOne ( conf, new VCSVMLight(conf) );
|
|
|
- } else if ( (classifier_type == "svm_onevsall") ) {
|
|
|
- classifier = new VCOneVsAll ( conf, new VCSVMLight(conf) );
|
|
|
- } else if ( (classifier_type == "svmlight_kernel")) {
|
|
|
- classifier = new KCSVMLight ( conf, new KernelStd() );
|
|
|
- } else if ( (classifier_type == "svm_one_class")) {
|
|
|
- classifier = new VCSVMOneClass( conf, "VCSVMLight" );
|
|
|
+ } else if ( ( classifier_type == "svmlight" ) || ( classifier_type == "svm" ) ) {
|
|
|
+ classifier = new VCSVMLight ( conf );
|
|
|
+ } else if ( ( classifier_type == "svm_onevsone" ) ) {
|
|
|
+ classifier = new VCOneVsOne ( conf, new VCSVMLight ( conf ) );
|
|
|
+ } else if ( ( classifier_type == "svm_onevsall" ) ) {
|
|
|
+ classifier = new VCOneVsAll ( conf, new VCSVMLight ( conf ) );
|
|
|
+ } else if ( ( classifier_type == "svmlight_kernel" ) ) {
|
|
|
+ classifier = new KCSVMLight ( conf, new KernelStd() );
|
|
|
+ } else if ( ( classifier_type == "svm_one_class" ) ) {
|
|
|
+ classifier = new VCSVMOneClass ( conf, "VCSVMLight" );
|
|
|
#endif
|
|
|
#ifdef NICE_USELIB_NICEDTSVM
|
|
|
- // this classifier requires nice-dtsvm, which is an optional
|
|
|
- // nice sub-library
|
|
|
- } else if ( classifier_type == "treebased" ) {
|
|
|
- classifier = new VCTreeBasedClassifier ( conf );
|
|
|
+ // this classifier requires nice-dtsvm, which is an optional
|
|
|
+ // nice sub-library
|
|
|
+ } else if ( classifier_type == "treebased" ) {
|
|
|
+ classifier = new VCTreeBasedClassifier ( conf );
|
|
|
#endif
|
|
|
- } else if ( (classifier_type == "dtgp") ) {
|
|
|
- classifier = new VCDTSVM ( conf );
|
|
|
- } else if ( (classifier_type == "minimum_enclosing_ball")) {
|
|
|
- string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
|
|
|
- classifier = new KCMinimumEnclosingBall ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
- } else if ( (classifier_type == "gp_one_class")) {
|
|
|
- string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
|
|
|
- classifier = new KCGPOneClass ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
- } else if ( (classifier_type == "gp_regression_rbf")) {
|
|
|
- string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
|
|
|
- classifier = new KCGPRegression ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
- } else if ( (classifier_type == "gp_laplace_rbf")) {
|
|
|
- string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
|
|
|
- classifier = new KCGPLaplace ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
- } else if ( (classifier_type == "gp_regression_rbf_onevsall" ) ) {
|
|
|
- string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
|
|
|
- classifier = new KCGPRegOneVsAll ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
- } else if ( (classifier_type == "gp_laplace_rbf_onevsall" ) ) {
|
|
|
- string kernel_type = conf->gS("Kernel", "kernel_function", "rbf" );
|
|
|
- classifier = new KCGPLaplaceOneVsAll ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
- } else if ( StringTools::regexMatch ( classifier_type, "^one_vs_one\\(([^\\)]+)\\)$", submatches ) && (submatches.size() == 2)) {
|
|
|
- classifier = new VCOneVsOne ( conf, selectVecClassifier( conf, submatches[1] ) );
|
|
|
- } else if ( StringTools::regexMatch ( classifier_type, "^one_vs_all\\(([^\\)]+)\\)$", submatches ) && (submatches.size() == 2)) {
|
|
|
- classifier = new VCOneVsAll ( conf, selectVecClassifier( conf, submatches[1] ) );
|
|
|
- } else if ( StringTools::regexMatch ( classifier_type, "^random_forest\\(([^\\)]+)\\)$", submatches ) && (submatches.size() == 2)) {
|
|
|
- classifier = new VCPreRandomForest ( conf, "VCPreRandomForest", selectVecClassifier(conf, submatches[1] ) );
|
|
|
- } else {
|
|
|
- fthrow ( Exception, "Classifier type " << classifier_type << " not (yet) supported." << endl <<
|
|
|
- "(genericClassifierSelection.h contains a list of classifiers to choose from)");
|
|
|
- }
|
|
|
-
|
|
|
- return classifier;
|
|
|
- }
|
|
|
+ } else if ( ( classifier_type == "dtgp" ) ) {
|
|
|
+ classifier = new VCDTSVM ( conf );
|
|
|
+ } else if ( ( classifier_type == "minimum_enclosing_ball" ) ) {
|
|
|
+ string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
|
|
|
+ classifier = new KCMinimumEnclosingBall ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
+ } else if ( ( classifier_type == "gp_one_class" ) ) {
|
|
|
+ string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
|
|
|
+ classifier = new KCGPOneClass ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
+ } else if ( ( classifier_type == "gp_regression_rbf" ) ) {
|
|
|
+ string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
|
|
|
+ classifier = new KCGPRegression ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
+ } else if ( ( classifier_type == "gp_laplace_rbf" ) ) {
|
|
|
+ string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
|
|
|
+ classifier = new KCGPLaplace ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
+ } else if ( ( classifier_type == "gp_regression_rbf_onevsall" ) ) {
|
|
|
+ string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
|
|
|
+ classifier = new KCGPRegOneVsAll ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
+ } else if ( ( classifier_type == "gp_laplace_rbf_onevsall" ) ) {
|
|
|
+ string kernel_type = conf->gS ( "Kernel", "kernel_function", "rbf" );
|
|
|
+ classifier = new KCGPLaplaceOneVsAll ( conf, GenericKernelSelection::selectKernel ( conf, kernel_type ) );
|
|
|
+ } else if ( StringTools::regexMatch ( classifier_type, "^one_vs_one\\(([^\\)]+)\\)$", submatches ) && ( submatches.size() == 2 ) ) {
|
|
|
+ classifier = new VCOneVsOne ( conf, selectVecClassifier ( conf, submatches[1] ) );
|
|
|
+ } else if ( StringTools::regexMatch ( classifier_type, "^one_vs_all\\(([^\\)]+)\\)$", submatches ) && ( submatches.size() == 2 ) ) {
|
|
|
+ classifier = new VCOneVsAll ( conf, selectVecClassifier ( conf, submatches[1] ) );
|
|
|
+ } else if ( StringTools::regexMatch ( classifier_type, "^random_forest\\(([^\\)]+)\\)$", submatches ) && ( submatches.size() == 2 ) ) {
|
|
|
+ classifier = new VCPreRandomForest ( conf, "VCPreRandomForest", selectVecClassifier ( conf, submatches[1] ) );
|
|
|
+ } else {
|
|
|
+ fthrow ( Exception, "Classifier type " << classifier_type << " not (yet) supported." << endl <<
|
|
|
+ "(genericClassifierSelection.h contains a list of classifiers to choose from)" );
|
|
|
+ }
|
|
|
+
|
|
|
+ return classifier;
|
|
|
+ }
|
|
|
|
|
|
};
|
|
|
|