[mlpack-svn] r11612 - mlpack/trunk/src/mlpack/tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Feb 27 16:23:16 EST 2012


Author: rcurtin
Date: 2012-02-27 16:23:16 -0500 (Mon, 27 Feb 2012)
New Revision: 11612

Modified:
   mlpack/trunk/src/mlpack/tests/kernel_pca_test.cpp
Log:
A couple changes to the kernel PCA test.


Modified: mlpack/trunk/src/mlpack/tests/kernel_pca_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/kernel_pca_test.cpp	2012-02-27 21:07:50 UTC (rev 11611)
+++ mlpack/trunk/src/mlpack/tests/kernel_pca_test.cpp	2012-02-27 21:23:16 UTC (rev 11612)
@@ -14,6 +14,7 @@
 
 using namespace mlpack;
 using namespace mlpack::kpca;
+using namespace mlpack::kernel;
 using namespace std;
 using namespace arma;
 
@@ -24,26 +25,26 @@
             "5 2 8 4 8;"
             "6 7 3 1 8");
 
-  kpca::KernelPCA<kernel::LinearKernel> p;
+  KernelPCA<LinearKernel> p;
   p.Apply(data, 2); // Reduce to 2 dimensions.
 
   // Compare with correct results.
   mat correct("-1.53781086 -3.51358020 -0.16139887 -1.87706634  7.08985628;"
-               " 1.29937798  3.45762685 -2.69910005 -3.15620704  1.09830225");
+              " 1.29937798  3.45762685 -2.69910005 -3.15620704  1.09830225");
 
   // If the eigenvectors are pointed opposite directions, they will cancel
   // each other out in this summation.
   for(size_t i = 0; i < data.n_rows; i++)
   {
-    if (fabs(correct(i, 1) + data(i,1)) < 0.001 /* arbitrary */)
+    if (fabs(correct(i, 1) + data(i, 1)) < 0.001 /* arbitrary */)
     {
-         // Flip Armadillo coefficients for this column.
+         // Flip eigenvector for this column (negate output).
          data.row(i) *= -1;
     }
   }
 
-  for (size_t row = 0; row < 2; row++)
-    for (size_t col = 0; col < 5; col++)
+  for (size_t row = 0; row < 2; ++row)
+    for (size_t col = 0; col < 5; ++col)
       BOOST_REQUIRE_CLOSE(data(row, col), correct(row, col), 1e-3);
 }
 




More information about the mlpack-svn mailing list