[mlpack] 73/207: Test for outliers.

Barak A. Pearlmutter barak+git at pearlmutter.net
Thu Mar 23 17:53:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch master
in repository mlpack.

commit 95143cfefaeabe1c116946a340d170cc11c306f9
Author: Ryan Curtin <ryan at ratml.org>
Date:   Thu Aug 4 15:57:33 2016 -0400

    Test for outliers.
---
 src/mlpack/tests/dbscan_test.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/mlpack/tests/dbscan_test.cpp b/src/mlpack/tests/dbscan_test.cpp
index e3f70db..94bccda 100644
--- a/src/mlpack/tests/dbscan_test.cpp
+++ b/src/mlpack/tests/dbscan_test.cpp
@@ -50,4 +50,28 @@ BOOST_AUTO_TEST_CASE(TinyEpsilonTest)
     BOOST_REQUIRE_EQUAL(assignments[i], SIZE_MAX);
 }
 
+/**
+ * Check that outliers are properly labeled as noise.
+ */
+BOOST_AUTO_TEST_CASE(OutlierTest)
+{
+  arma::mat points(2, 200, arma::fill::randu);
+
+  // Add 3 outliers.
+  points.col(15) = arma::vec("10.3 1.6");
+  points.col(45) = arma::vec("-100 0.0");
+  points.col(101) = arma::vec("1.5 1.5");
+
+  DBSCAN<> d(0.1, 3);
+
+  arma::Row<size_t> assignments;
+  const size_t clusters = d.Cluster(points, assignments);
+
+  BOOST_REQUIRE_GT(clusters, 0);
+  BOOST_REQUIRE_EQUAL(assignments.n_elem, points.n_cols);
+  BOOST_REQUIRE_EQUAL(assignments[15], SIZE_MAX);
+  BOOST_REQUIRE_EQUAL(assignments[45], SIZE_MAX);
+  BOOST_REQUIRE_EQUAL(assignments[101], SIZE_MAX);
+}
+
 BOOST_AUTO_TEST_SUITE_END();

-- 
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