[mlpack-svn] r11675 - mlpack/trunk/src/mlpack/methods/lars

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Mar 1 00:53:28 EST 2012


Author: niche
Date: 2012-03-01 00:53:28 -0500 (Thu, 01 Mar 2012)
New Revision: 11675

Modified:
   mlpack/trunk/src/mlpack/methods/lars/lars.cpp
Log:
fixed small bug in lars: sometimes after kicking a dimension out of the active set, we also need to explicitly set the corresponding coefficient to zero. In that case, we were saving beta to the end of the beta path before the fix. now, we save beta after the fix. This fixes a bug

Modified: mlpack/trunk/src/mlpack/methods/lars/lars.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/lars/lars.cpp	2012-03-01 03:57:15 UTC (rev 11674)
+++ mlpack/trunk/src/mlpack/methods/lars/lars.cpp	2012-03-01 05:53:28 UTC (rev 11675)
@@ -101,12 +101,12 @@
     return;
   }
 
-  //u32 matX.n_rowsiterations_run = 0;
+  //u32 iterations_run = 0;
   // MAIN LOOP
   while ((nActive < matX.n_cols) && (maxCorr > EPS))
   {
-    //matX.n_rowsiterations_run++;
-    //printf("iteration %d\t", matX.n_rowsiterations_run);
+    //iterations_run++;
+    //printf("iteration %d\t\n", iterations_run);
 
     // explicit computation of max correlation, among inactive indices
     changeInd = -1;
@@ -242,9 +242,9 @@
 
       if (lassoboundOnGamma < gamma)
       {
-        //printf("%d: gap = %e\tbeta(%d) = %e\n",
+        // printf("%d: gap = %e\tbeta(%d) = %e\n",
         //    activeSet[activeIndToKickOut],
-        //    gamma - lassoBoundOnGamma,
+        //    gamma - lassoboundOnGamma,
         //    activeSet[activeIndToKickOut],
         //    beta(activeSet[activeIndToKickOut]));
         gamma = lassoboundOnGamma;
@@ -261,18 +261,24 @@
     {
       beta(activeSet[i]) += gamma * betaDirection(i);
     }
-    betaPath.push_back(beta);
 
+    // sanity check to make sure the kicked out guy (or girl?) is actually zero
     if (lassocond)
     {
-      // index is in position changeInd in activeSet
-      //printf("\t\tKICK OUT %d!\n", activeSet[changeInd]);
       if (beta(activeSet[changeInd]) != 0)
       {
         //printf("fixed from %e to 0\n", beta(activeSet[changeInd]));
         beta(activeSet[changeInd]) = 0;
       }
+    }
+    
+    betaPath.push_back(beta);
 
+    if (lassocond)
+    {
+      // index is in position changeInd in activeSet
+      //printf("\t\tKICK OUT %d!\n", activeSet[changeInd]);
+
       if (useCholesky)
       {
         CholeskyDelete(changeInd);




More information about the mlpack-svn mailing list