Ver Fonte

workaround for failing cholesky decomp

Sven Sickert há 10 anos atrás
pai
commit
1d3b1f7514
1 ficheiros alterados com 13 adições e 8 exclusões
  1. 13 8
      classifier/fpclassifier/randomforest/DTBOblique.cpp

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

@@ -113,7 +113,6 @@ void DTBOblique::getDataAndLabel(
         const Example & ce = p.second;
 
         NICE::Vector pixelRepr = f->getFeatureVector( &ce );
-        pixelRepr /= pixelRepr.Max();
 
         double label = p.first * ce.weight;
         pixelRepr *= ce.weight;
@@ -248,19 +247,25 @@ DecisionNode *DTBOblique::buildRecursive(
     NICE::Vector best_beta = f->getParameterVector();
 
     // Creating data matrix X and label vector y
-    NICE::Matrix X, XTXr, G;
+    NICE::Matrix X, XTXr, G, temp;
     NICE::Vector y, beta;
     getDataAndLabel( fp, examples, examples_selection, X, y );
 
     // Preparing system of linear equations
-    //NICE::Matrix XTX = X.transpose()*X;
     regularizeDataMatrix( X, XTXr, regularizationType, lambdaCurrent );
-//    R *= lambdaCurrent;
 
-    //choleskyDecomp(XTXr, G);
-    //choleskyInvert(G, XTXr);
-    G = NICE::invert(XTXr);
-    NICE::Matrix temp = G * X.transpose();
+    if (regularizationType == 3)
+    {
+        G = NICE::invert(XTXr);
+        temp = G * X.transpose();
+    }
+    else
+    {
+        choleskyDecomp(XTXr, G);
+        choleskyInvert(G, XTXr);
+        temp = XTXr * X.transpose();
+    }
+
 
     for ( int curClass = 0; curClass <= maxClassNo; curClass++ )
     {