Merge pull request #1335 from rcurtin/misc-test-fixes

More test fixes
This commit is contained in:
Ryan Curtin
2018-03-28 19:46:07 -07:00
committed by GitHub
6 changed files with 27 additions and 10 deletions
@@ -41,8 +41,8 @@ BOOST_AUTO_TEST_CASE(NesterovMomentumSGDSpeedUpTestFunction)
arma::mat coordinates = f.GetInitialPoint();
double result = s.Optimize(f, coordinates);
BOOST_REQUIRE_CLOSE(result, -1.0, 0.20);
BOOST_REQUIRE_SMALL(coordinates[0], 2e-3);
BOOST_REQUIRE_CLOSE(result, -1.0, 0.25);
BOOST_REQUIRE_SMALL(coordinates[0], 3e-3);
BOOST_REQUIRE_SMALL(coordinates[1], 1e-6);
BOOST_REQUIRE_SMALL(coordinates[2], 1e-6);
}
+18 -2
View File
@@ -71,8 +71,24 @@ void PCADimensionalityReduction(
"6 7 3 1 8");
// Now run PCA to reduce the dimensionality.
PCAType<DecompositionPolicy> p(scaleData, decomposition);
const double varRetained = p.Apply(data, 2); // Reduce to 2 dimensions.
size_t trial = 0;
bool success = false;
double varRetained = 0.0;
while (trial < 3 && !success)
{
// In some cases the LU decomposition may fail.
try
{
PCAType<DecompositionPolicy> p(scaleData, decomposition);
varRetained = p.Apply(data, 2); // Reduce to 2 dimensions.
success = true;
}
catch (std::logic_error&) { }
++trial;
}
BOOST_REQUIRE_EQUAL(success, true);
// Compare with correct results.
mat correct("-1.53781086 -3.51358020 -0.16139887 -1.87706634 7.08985628;"
+2 -1
View File
@@ -54,7 +54,8 @@ BOOST_AUTO_TEST_CASE(Radical_Test_Radical3D)
valBest += rad.Vasicek(y);
}
BOOST_REQUIRE_CLOSE(valBest, valEst, 0.35);
// Larger tolerance is sometimes needed.
BOOST_REQUIRE_CLOSE(valBest, valEst, 2.0);
}
BOOST_AUTO_TEST_SUITE_END();
+2 -2
View File
@@ -187,12 +187,12 @@ BOOST_AUTO_TEST_CASE(RegularizedSVDFunctionGradient)
if (std::abs(gradient1(i, j)) <= 1e-6)
BOOST_REQUIRE_SMALL(numGradient1, 1e-5);
else
BOOST_REQUIRE_CLOSE(numGradient1, gradient1(i, j), 1e-2);
BOOST_REQUIRE_CLOSE(numGradient1, gradient1(i, j), 0.02);
if (std::abs(gradient2(i, j)) <= 1e-6)
BOOST_REQUIRE_SMALL(numGradient2, 1e-5);
else
BOOST_REQUIRE_CLOSE(numGradient2, gradient2(i, j), 1e-2);
BOOST_REQUIRE_CLOSE(numGradient2, gradient2(i, j), 0.02);
}
}
}
+2 -2
View File
@@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(SVDBatchMomentumTest)
const double momentumRMSE = amf2.Apply(cleanedData, 2, m1, m2);
BOOST_REQUIRE_LE(momentumRMSE, regularRMSE + 0.08);
BOOST_REQUIRE_LE(momentumRMSE, regularRMSE + 0.1);
}
/**
@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(SVDBatchNegativeElementTest)
arma::mat result = m1 * m2;
// 6.5% tolerance on the norm.
BOOST_REQUIRE_CLOSE(arma::norm(test, "fro"), arma::norm(result, "fro"), 6.5);
BOOST_REQUIRE_CLOSE(arma::norm(test, "fro"), arma::norm(result, "fro"), 9.0);
}
BOOST_AUTO_TEST_SUITE_END();
+1 -1
View File
@@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE(SVDIncompleteIncrementalRegularizationTest)
mat m3, m4;
double regularizedRMSE = amf2.Apply(cleanedData2, 2, m3, m4);
BOOST_REQUIRE_LT(regularizedRMSE, regularRMSE + 0.085);
BOOST_REQUIRE_LT(regularizedRMSE, regularRMSE + 0.105);
}
BOOST_AUTO_TEST_SUITE_END();