[mlpack-git] master: It isn't guaranteed that the QUIC-SVD will match with the results of the exact SVD method, so we test if the method is able to solve the task in one of 5 trails using different starting samples. (3a1bc90)

gitdub at mlpack.org gitdub at mlpack.org
Wed Jul 27 11:12:17 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/256d77dfc80c49b9136055536d6c58985e02a8de...3a1bc90ea5f1ffa45d2de000efb4429c60468b21

>---------------------------------------------------------------

commit 3a1bc90ea5f1ffa45d2de000efb4429c60468b21
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Wed Jul 27 17:12:07 2016 +0200

    It isn't guaranteed that the QUIC-SVD will match with the results of the exact SVD method, so we test if the method is able to solve the task in one of 5 trails using different starting samples.


>---------------------------------------------------------------

3a1bc90ea5f1ffa45d2de000efb4429c60468b21
 src/mlpack/tests/pca_test.cpp | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/mlpack/tests/pca_test.cpp b/src/mlpack/tests/pca_test.cpp
index 5176f88..22503a8 100644
--- a/src/mlpack/tests/pca_test.cpp
+++ b/src/mlpack/tests/pca_test.cpp
@@ -199,14 +199,30 @@ BOOST_AUTO_TEST_CASE(QUICPCADimensionalityReductionTest)
   data::Load("test_data_3_1000.csv", data);
   data1 = data;
 
-  PCAType<ExactSVDPolicy> exactPCA;
-  const double varRetainedExact = exactPCA.Apply(data, 1);
+  // It isn't guaranteed that the QUIC-SVD will match with the exact SVD method,
+  // starting with random samples. If this works 1 of 5 times, I'm fine with
+  // that. All I want to know is that the QUIC-SVD method is  able to solve the
+  // task and is at least as good as the exact method (plus a little bit for
+  // noise).
+  size_t successes = 0;
+  for (size_t trial = 0; trial < 5; ++trial)
+  {
+
+    PCAType<ExactSVDPolicy> exactPCA;
+    const double varRetainedExact = exactPCA.Apply(data, 1);
+
+    PCAType<QUICSVDPolicy> quicPCA;
+    const double varRetainedQUIC = quicPCA.Apply(data1, 1);
 
-  PCAType<QUICSVDPolicy> quicPCA;
-  const double varRetainedQUIC = quicPCA.Apply(data1, 1);
 
-  BOOST_REQUIRE_CLOSE(varRetainedExact, varRetainedQUIC, 4.0);
+    if (std::abs(varRetainedExact - varRetainedQUIC) < 0.2)
+    {
+      ++successes;
+      break;
+    }
+  }
 
+  BOOST_REQUIRE_GE(successes, 1);
   BOOST_REQUIRE_EQUAL(data.n_rows, data1.n_rows);
   BOOST_REQUIRE_EQUAL(data.n_cols, data1.n_cols);
 }




More information about the mlpack-git mailing list