Browse Source

DTBOblique: optional dynamic regularization

Sven Sickert 10 years ago
parent
commit
1fae95f3cd

+ 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);
     useShannonEntropy = conf->gB( section, "use_shannon_entropy", 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 );
     maxDepth = conf->gI( section, "max_depth", 10 );
@@ -239,8 +240,6 @@ void DTBOblique::regularizeDataMatrix(
             q[0] = 1.0;
             NICE::Matrix Q;
             Q.tensorProduct(q,q);
-            //R.multiply(XTXreg,Q);
-            // element-wise multiplication
             R.resize(dim,dim);
             for ( int r = 0; r < dim; r++ )
             {
@@ -495,16 +494,21 @@ DecisionNode *DTBOblique::buildRecursive(
     delete [] bestSplitInfo.distRight;
 
     // 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()));
-    double lambdaRight = lambdaCurrent *
+        lambdaRight = lambdaCurrent *
             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 */
     // 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 */
     bool useOneVsOne;
 
+    /** Whether to increase the influence of regularization over time or not */
+    bool useDynamicRegularization;
+
     /** Amount of steps for complete search for best threshold */
     int splitSteps;