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

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Sat Apr 26 08:40:04 EDT 2014


Author: rcurtin
Date: Sat Apr 26 08:40:03 2014
New Revision: 16468

Log:
Rewrite NMFALSTest so that random failures should be less likely.


Modified:
   mlpack/trunk/src/mlpack/tests/nmf_test.cpp

Modified: mlpack/trunk/src/mlpack/tests/nmf_test.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/tests/nmf_test.cpp	(original)
+++ mlpack/trunk/src/mlpack/tests/nmf_test.cpp	Sat Apr 26 08:40:03 2014
@@ -102,11 +102,13 @@
       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-svn mailing list