[mlpack] 05/35: Fix test: the fourth Gaussian should not be part of the mixture.
Barak A. Pearlmutter
barak+git at pearlmutter.net
Thu Sep 15 23:29:38 UTC 2016
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch master
in repository mlpack.
commit 102fc20662aa2dd37629d27d507b5056cbcd458b
Author: Ryan Curtin <ryan at ratml.org>
Date: Fri Jul 1 12:05:29 2016 -0400
Fix test: the fourth Gaussian should not be part of the mixture.
---
src/mlpack/tests/gmm_test.cpp | 38 ++++++++++++++------------------------
1 file changed, 14 insertions(+), 24 deletions(-)
diff --git a/src/mlpack/tests/gmm_test.cpp b/src/mlpack/tests/gmm_test.cpp
index 7139722..356f5c9 100644
--- a/src/mlpack/tests/gmm_test.cpp
+++ b/src/mlpack/tests/gmm_test.cpp
@@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE(GMMTrainEMMultipleGaussiansWithProbability)
}
// Now train the model.
- GMM g(4, 3); // 3 dimensions, 4 components.
+ GMM g(3, 3); // 3 dimensions, 3 components (the fourth component is fake).
g.Train(points, probabilities, 8);
@@ -323,53 +323,43 @@ BOOST_AUTO_TEST_CASE(GMMTrainEMMultipleGaussiansWithProbability)
// The tolerances in our checks are quite large, but it is good to remember
// that we introduced a fair amount of random noise into this whole process.
+ // We don't need to look for the fourth Gaussian since that is not supposed to
+ // be a part of this mixture.
- // First Gaussian (d4).
- BOOST_REQUIRE_SMALL(g.Weights()[sortedIndices[0]] - 0.1, 0.1);
+ // First Gaussian (d1).
+ BOOST_REQUIRE_SMALL(g.Weights()[sortedIndices[0]] - 0.2, 0.1);
for (size_t i = 0; i < 3; i++)
BOOST_REQUIRE_SMALL((g.Component(sortedIndices[0]).Mean()[i]
- - d4.Mean()[i]), 0.4);
-
- for (size_t row = 0; row < 3; row++)
- for (size_t col = 0; col < 3; col++)
- BOOST_REQUIRE_SMALL((g.Component(sortedIndices[0]).Covariance()(row, col)
- - d4.Covariance()(row, col)), 0.7); // Big tolerance! Lots of noise.
-
- // Second Gaussian (d1).
- BOOST_REQUIRE_SMALL(g.Weights()[sortedIndices[1]] - 0.2, 0.1);
-
- for (size_t i = 0; i < 3; i++)
- BOOST_REQUIRE_SMALL((g.Component(sortedIndices[1]).Mean()[i]
- d1.Mean()[i]), 0.4);
for (size_t row = 0; row < 3; row++)
for (size_t col = 0; col < 3; col++)
- BOOST_REQUIRE_SMALL((g.Component(sortedIndices[1]).Covariance()(row, col)
+ BOOST_REQUIRE_SMALL((g.Component(sortedIndices[0]).Covariance()(row, col)
- d1.Covariance()(row, col)), 0.7); // Big tolerance! Lots of noise.
- // Third Gaussian (d2).
- BOOST_REQUIRE_SMALL(g.Weights()[sortedIndices[2]] - 0.3, 0.1);
+ // Second Gaussian (d2).
+ BOOST_REQUIRE_SMALL(g.Weights()[sortedIndices[1]] - 0.3, 0.1);
for (size_t i = 0; i < 3; i++)
- BOOST_REQUIRE_SMALL((g.Component(sortedIndices[2]).Mean()[i]
+ BOOST_REQUIRE_SMALL((g.Component(sortedIndices[1]).Mean()[i]
- d2.Mean()[i]), 0.4);
for (size_t row = 0; row < 3; row++)
for (size_t col = 0; col < 3; col++)
- BOOST_REQUIRE_SMALL((g.Component(sortedIndices[2]).Covariance()(row, col)
+ BOOST_REQUIRE_SMALL((g.Component(sortedIndices[1]).Covariance()(row, col)
- d2.Covariance()(row, col)), 0.7); // Big tolerance! Lots of noise.
- // Fourth gaussian (d3).
- BOOST_REQUIRE_SMALL(g.Weights()[sortedIndices[3]] - 0.4, 0.1);
+ // Third Gaussian (d3).
+ BOOST_REQUIRE_SMALL(g.Weights()[sortedIndices[2]] - 0.4, 0.1);
for (size_t i = 0; i < 3; ++i)
- BOOST_REQUIRE_SMALL((g.Component(sortedIndices[3]).Mean()[i]
+ BOOST_REQUIRE_SMALL((g.Component(sortedIndices[2]).Mean()[i]
- d3.Mean()[i]), 0.4);
for (size_t row = 0; row < 3; ++row)
for (size_t col = 0; col < 3; ++col)
- BOOST_REQUIRE_SMALL((g.Component(sortedIndices[3]).Covariance()(row, col)
+ BOOST_REQUIRE_SMALL((g.Component(sortedIndices[2]).Covariance()(row, col)
- d3.Covariance()(row, col)), 0.7);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list