[mlpack-git] master, mlpack-1.0.x: Rewrite NMFALSTest so that random failures should be less likely. (d941b4a)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:47:01 EST 2015


Repository : https://github.com/mlpack/mlpack

On branches: master,mlpack-1.0.x
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit d941b4a54595cae566a8b1e41cb106565b27f645
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sat Apr 26 12:40:03 2014 +0000

    Rewrite NMFALSTest so that random failures should be less likely.


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

d941b4a54595cae566a8b1e41cb106565b27f645
 src/mlpack/tests/nmf_test.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mlpack/tests/nmf_test.cpp b/src/mlpack/tests/nmf_test.cpp
index 6e5f188..30f0720 100644
--- a/src/mlpack/tests/nmf_test.cpp
+++ b/src/mlpack/tests/nmf_test.cpp
@@ -102,11 +102,13 @@ BOOST_AUTO_TEST_CASE(NMFALSTest)
       HAlternatingLeastSquaresRule> nmf(50000, 1e-15);
   nmf.Apply(v, r, w, h);
 
-  mat wh = w * h;
+  const mat wh = w * h;
 
-  for (size_t row = 0; row < 20; row++)
-    for (size_t col = 0; col < 20; col++)
-      BOOST_REQUIRE_CLOSE(v(row, col), wh(row, col), 18.0);
+  const double error = arma::accu(arma::abs(v - wh)) / arma::accu(v);
+
+  // Most runs seem to produce error between 0.01 and 0.03.
+  // This is a randomized test, so we don't really have guarantees.
+  BOOST_REQUIRE_SMALL(error, 0.04);
 }
 
 /**



More information about the mlpack-git mailing list