Ver código fonte

using namespace in header entfernt...

Björn Fröhlich 13 anos atrás
pai
commit
4605b5140a
2 arquivos alterados com 30 adições e 25 exclusões
  1. 4 4
      classifier/genericClassifierSelection.h
  2. 26 21
      math/kernels/genericKernel.h

+ 4 - 4
classifier/genericClassifierSelection.h

@@ -124,14 +124,14 @@ class GenericClassifierSelection
       } else if ( ( classifier_type == "gp_laplace_rbf_onevsall" ) ) {
         std::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 ) ) {
+      } else if ( NICE::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 ) ) {
+      } else if ( NICE::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 ) ) {
+      } else if ( NICE::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." << std::endl <<
+        fthrow ( NICE::Exception, "Classifier type " << classifier_type << " not (yet) supported." << std::endl <<
                  "(genericClassifierSelection.h contains a list of classifiers to choose from)" );
       }
 

+ 26 - 21
math/kernels/genericKernel.h

@@ -1,34 +1,39 @@
 #ifndef _NICE_OBJREC_GENERICKERNELSELECTION_INCLUDE
 #define _NICE_OBJREC_GENERICKERNELSELECTION_INCLUDE
 
-
 #include <vector>
 #include "KernelRBF.h"
 #include "KernelExp.h"
 
-namespace OBJREC {
+namespace OBJREC
+{
 
 class GenericKernelSelection
 {
-    public:
-
-		static Kernel *selectKernel ( const NICE::Config *conf, std::string kernel_type )
-		{
-			Kernel *kernel = NULL;
-
-			if ( kernel_type == "rbf" ) {
-				double log_rbf_gamma = conf->gD("Kernel","log_rbf_gamma",-2.5);
-				kernel = new KernelRBF (log_rbf_gamma);
-			} else if ( kernel_type == "exp" ) {
-				double log_rbf_gamma = conf->gD("Kernel","log_rbf_gamma",-2.5);
-				double log_rbf_sv = conf->gD("Kernel","log_rbf_sv",0.0);
-				kernel = new KernelExp (log_rbf_gamma, log_rbf_sv);
-			} else {
-				fthrow(Exception, "Kernel type " << kernel_type << " is unknown" );
-			}
-
-			return kernel;
-		}
+  public:
+
+    static Kernel *selectKernel ( const NICE::Config *conf, std::string kernel_type )
+    {
+      Kernel *kernel = NULL;
+
+      if ( kernel_type == "rbf" )
+      {
+        double log_rbf_gamma = conf->gD ( "Kernel","log_rbf_gamma",-2.5 );
+        kernel = new KernelRBF ( log_rbf_gamma );
+      }
+      else if ( kernel_type == "exp" )
+      {
+        double log_rbf_gamma = conf->gD ( "Kernel","log_rbf_gamma",-2.5 );
+        double log_rbf_sv = conf->gD ( "Kernel","log_rbf_sv",0.0 );
+        kernel = new KernelExp ( log_rbf_gamma, log_rbf_sv );
+      }
+      else
+      {
+        fthrow ( NICE::Exception, "Kernel type " << kernel_type << " is unknown" );
+      }
+
+      return kernel;
+    }
 
 };