Преглед на файлове

DTBOblique: optional dynamic regularization

Sven Sickert преди 10 години
родител
ревизия
1fae95f3cd
променени са 2 файла, в които са добавени 16 реда и са изтрити 9 реда
  1. 13 9
      classifier/fpclassifier/randomforest/DTBOblique.cpp
  2. 3 0
      classifier/fpclassifier/randomforest/DTBOblique.h

+ 13 - 9
classifier/fpclassifier/randomforest/DTBOblique.cpp

@@ -26,6 +26,7 @@ DTBOblique::DTBOblique ( const Config *conf, string section )
     saveIndices = conf->gB( section, "save_indices", false);
     saveIndices = conf->gB( section, "save_indices", false);
     useShannonEntropy = conf->gB( section, "use_shannon_entropy", false );
     useShannonEntropy = conf->gB( section, "use_shannon_entropy", false );
     useOneVsOne = conf->gB( section, "use_one_vs_one", false );
     useOneVsOne = conf->gB( section, "use_one_vs_one", false );
+    useDynamicRegularization = conf->gB( section, "use_dynamic_regularization", true );
 
 
     splitSteps = conf->gI( section, "split_steps", 20 );
     splitSteps = conf->gI( section, "split_steps", 20 );
     maxDepth = conf->gI( section, "max_depth", 10 );
     maxDepth = conf->gI( section, "max_depth", 10 );
@@ -239,8 +240,6 @@ void DTBOblique::regularizeDataMatrix(
             q[0] = 1.0;
             q[0] = 1.0;
             NICE::Matrix Q;
             NICE::Matrix Q;
             Q.tensorProduct(q,q);
             Q.tensorProduct(q,q);
-            //R.multiply(XTXreg,Q);
-            // element-wise multiplication
             R.resize(dim,dim);
             R.resize(dim,dim);
             for ( int r = 0; r < dim; r++ )
             for ( int r = 0; r < dim; r++ )
             {
             {
@@ -495,16 +494,21 @@ DecisionNode *DTBOblique::buildRecursive(
     delete [] bestSplitInfo.distRight;
     delete [] bestSplitInfo.distRight;
 
 
     // update lambda by heuristic [Laptev/Buhmann, 2014]
     // update lambda by heuristic [Laptev/Buhmann, 2014]
-    double lambdaLeft = lambdaCurrent *
+    double lambdaLeft, lambdaRight;
+
+    if (useDynamicRegularization)
+    {
+        lambdaLeft = lambdaCurrent *
             pow(((double)examples_selection.size()/(double)examples_left.size()),(2./f->getParameterLength()));
             pow(((double)examples_selection.size()/(double)examples_left.size()),(2./f->getParameterLength()));
-    double lambdaRight = lambdaCurrent *
+        lambdaRight = lambdaCurrent *
             pow(((double)examples_selection.size()/(double)examples_right.size()),(2./f->getParameterLength()));
             pow(((double)examples_selection.size()/(double)examples_right.size()),(2./f->getParameterLength()));
+    }
+    else
+    {
+        lambdaLeft = lambdaCurrent;
+        lambdaRight = lambdaCurrent;
+    }
 
 
-//#ifdef DEBUGTREE
-//    std::cerr << "regularization parameter lambda left " << lambdaLeft
-//              << " right " << lambdaRight << std::endl;
-
-//#endif
 
 
     /** Recursion */
     /** Recursion */
     // left child
     // left child

+ 3 - 0
classifier/fpclassifier/randomforest/DTBOblique.h

@@ -48,6 +48,9 @@ class DTBOblique : public DecisionTreeBuilder
     /** Whether to use one-vs-one or one-vs-all for multiclass scenarios */
     /** Whether to use one-vs-one or one-vs-all for multiclass scenarios */
     bool useOneVsOne;
     bool useOneVsOne;
 
 
+    /** Whether to increase the influence of regularization over time or not */
+    bool useDynamicRegularization;
+
     /** Amount of steps for complete search for best threshold */
     /** Amount of steps for complete search for best threshold */
     int splitSteps;
     int splitSteps;