[mlpack-git] master: Add test: equally good features should not split. (2d5fb03)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Wed Dec 23 11:42:46 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/de9cc4b05069e1fa4793d9355f2f595af5ff45d2...6070527af14296cd99739de6c62666cc5d2a2125
>---------------------------------------------------------------
commit 2d5fb03f82e5fc8eaa7b999015c7ef8a8402bbdd
Author: ryan <ryan at ratml.org>
Date: Thu Sep 24 11:03:13 2015 -0400
Add test: equally good features should not split.
>---------------------------------------------------------------
2d5fb03f82e5fc8eaa7b999015c7ef8a8402bbdd
src/mlpack/tests/hoeffding_tree_test.cpp | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/mlpack/tests/hoeffding_tree_test.cpp b/src/mlpack/tests/hoeffding_tree_test.cpp
index d34f945..0bab98d 100644
--- a/src/mlpack/tests/hoeffding_tree_test.cpp
+++ b/src/mlpack/tests/hoeffding_tree_test.cpp
@@ -348,6 +348,32 @@ BOOST_AUTO_TEST_CASE(HoeffdingSplitAlmostPerfectSplit)
}
/**
+ * Test that the HoeffdingSplit class will not split if the two features are
+ * equally good.
+ */
+BOOST_AUTO_TEST_CASE(HoeffdingSplitEqualSplitTest)
+{
+ // Two categories and two dimensions.
+ data::DatasetInfo info;
+ info.MapString("cat0", 0);
+ info.MapString("cat1", 0);
+ info.MapString("cat0", 1);
+ info.MapString("cat1", 1);
+
+ HoeffdingSplit<> split(2, 2, info, 0.95);
+
+ // Feed samples.
+ for (size_t i = 0; i < 500; ++i)
+ {
+ split.Train(arma::Col<size_t>("0 0"), 0);
+ split.Train(arma::Col<size_t>("1 1"), 1);
+ }
+
+ // Ensure that splitting should not happen.
+ BOOST_REQUIRE_EQUAL(split.SplitCheck(), 0);
+}
+
+/**
* Build a decision tree on a dataset with two meaningless dimensions and ensure
* that it can properly classify all of the training points. (The dataset is
* perfectly separable.)
More information about the mlpack-git
mailing list