[mlpack] 47/207: Test the probabilities also.

Barak A. Pearlmutter barak+git at pearlmutter.net
Thu Mar 23 17:53:39 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 02d8fb5b737e40f07046adabfc011a45d0560d1e
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jan 23 13:23:09 2017 -0500

    Test the probabilities also.
---
 src/mlpack/tests/decision_tree_test.cpp | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/mlpack/tests/decision_tree_test.cpp b/src/mlpack/tests/decision_tree_test.cpp
index 5d57340..e2b0f31 100644
--- a/src/mlpack/tests/decision_tree_test.cpp
+++ b/src/mlpack/tests/decision_tree_test.cpp
@@ -368,11 +368,22 @@ BOOST_AUTO_TEST_CASE(PerfectTrainingSet)
   DecisionTree<> d(dataset, labels, 3, 1); // Minimum leaf size of 1.
 
   // Make sure that we can get perfect accuracy on the training set.
-  arma::Row<size_t> predictions;
-  d.Classify(dataset, predictions);
-
   for (size_t i = 0; i < 1000; ++i)
-    BOOST_REQUIRE_EQUAL(predictions[i], labels[i]);
+  {
+    size_t prediction;
+    arma::vec probabilities;
+    d.Classify(dataset.col(i), prediction, probabilities);
+
+    BOOST_REQUIRE_EQUAL(prediction, labels[i]);
+    BOOST_REQUIRE_EQUAL(probabilities.n_elem, 3);
+    for (size_t j = 0; j < 3; ++j)
+    {
+      if (labels[i] == j)
+        BOOST_REQUIRE_CLOSE(probabilities[j], 1.0, 1e-5);
+      else
+        BOOST_REQUIRE_SMALL(probabilities[j], 1e-5);
+    }
+  }
 }
 
 /**

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