[mlpack-git] master, mlpack-1.0.x: Ball tree tests for EMST. (d6f7ef5)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:54:27 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 d6f7ef57d2f95c2bef5dc348403190aff376372f
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Jul 25 16:08:25 2014 +0000

    Ball tree tests for EMST.


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

d6f7ef57d2f95c2bef5dc348403190aff376372f
 src/mlpack/tests/emst_test.cpp | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/mlpack/tests/emst_test.cpp b/src/mlpack/tests/emst_test.cpp
index 06a0746..a6f3742 100644
--- a/src/mlpack/tests/emst_test.cpp
+++ b/src/mlpack/tests/emst_test.cpp
@@ -245,4 +245,37 @@ BOOST_AUTO_TEST_CASE(CoverTreeTest)
 
 }
 
+/**
+ * Test BinarySpaceTree with Ball Bound.
+ */
+BOOST_AUTO_TEST_CASE(BallTreeTest)
+{
+  arma::mat inputData;
+  if (!data::Load("test_data_3_1000.csv", inputData))
+    BOOST_FAIL("Cannot load test dataset test_data_3_1000.csv!");
+
+  typedef BinarySpaceTree<BallBound<>, DTBStat> TreeType;
+
+  // naive mode.
+  DualTreeBoruvka<> bst(inputData, true);
+  // Ball tree.
+  DualTreeBoruvka<EuclideanDistance,
+                  BinarySpaceTree<BallBound<>, DTBStat> > ballt(inputData);
+
+  arma::mat bstResults;
+  arma::mat ballResults;
+
+  // Run the algorithms.
+  bst.ComputeMST(bstResults);
+  ballt.ComputeMST(ballResults);
+
+  for (size_t i = 0; i < bstResults.n_cols; i++)
+  {
+    BOOST_REQUIRE_EQUAL(bstResults(0, i), ballResults(0, i));
+    BOOST_REQUIRE_EQUAL(bstResults(1, i), ballResults(1, i));
+    BOOST_REQUIRE_CLOSE(bstResults(2, i), ballResults(2, i), 1e-5);
+  }
+
+}
+
 BOOST_AUTO_TEST_SUITE_END();



More information about the mlpack-git mailing list