Răsfoiți Sursa

DTBOblique: fixed issue in splitting behavior

Sven Sickert 10 ani în urmă
părinte
comite
c122870142
1 a modificat fișierele cu 7 adăugiri și 2 ștergeri
  1. 7 2
      classifier/fpclassifier/randomforest/DTBObliqueLS.cpp

+ 7 - 2
classifier/fpclassifier/randomforest/DTBObliqueLS.cpp

@@ -57,6 +57,8 @@ bool DTBObliqueLS::entropyLeftRight (
 {
     count_left = 0;
     count_right = 0;
+    int count_unweighted_left = 0;
+    int count_unweighted_right = 0;
     for ( FeatureValuesUnsorted::const_iterator i = values.begin();
           i != values.end();
           i++ )
@@ -66,15 +68,18 @@ bool DTBObliqueLS::entropyLeftRight (
         if ( value < threshold ) {
             stat_left[classno] += i->fourth;
             count_left+=i->fourth;
+            count_unweighted_left++;
         }
         else
         {
             stat_right[classno] += i->fourth;
             count_right+=i->fourth;
+            count_unweighted_right++;
         }
     }
 
-    if ( (count_left == 0) || (count_right == 0) )
+    if (  (count_unweighted_left < minExamples)
+       || (count_unweighted_right < minExamples) )
         return false;
 
     entropy_left = 0.0;
@@ -358,7 +363,7 @@ DecisionNode *DTBObliqueLS::buildRecursive(
 
     // stop criteria: maxDepth, minExamples, min_entropy
     if (    ( e <= minimumEntropy )
-         || ( (int)examples_selection.size() < minExamples )
+//         || ( (int)examples_selection.size() < minExamples )
          || ( depth > maxDepth ) )
 
     {