From 8a168d1b266b7ac5971462b52c0cbe4731dc4d02 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Sat, 7 Sep 2019 14:34:47 -0400 Subject: [PATCH 1/2] Remove unnecessary column from braziltourism ARFF files. --- src/mlpack/tests/data/braziltourism.arff | 1 - src/mlpack/tests/data/braziltourism_test.arff | 1 - 2 files changed, 2 deletions(-) diff --git a/src/mlpack/tests/data/braziltourism.arff b/src/mlpack/tests/data/braziltourism.arff index 307bfb49a2..8584f28755 100644 --- a/src/mlpack/tests/data/braziltourism.arff +++ b/src/mlpack/tests/data/braziltourism.arff @@ -33,7 +33,6 @@ @attribute 'Active' {0,1,2,3,4,5,6} @attribute 'Passive' {0,1,2,3,4} @attribute 'Logged_income' REAL -@attribute 'Trips' {0,1,2,3,4,5} @data 41,0,2187.5,186.9,0,0,3,7.690514618 diff --git a/src/mlpack/tests/data/braziltourism_test.arff b/src/mlpack/tests/data/braziltourism_test.arff index 9e151fea30..103cbd173f 100644 --- a/src/mlpack/tests/data/braziltourism_test.arff +++ b/src/mlpack/tests/data/braziltourism_test.arff @@ -33,7 +33,6 @@ @attribute 'Active' {0,1,2,3,4,5,6} @attribute 'Passive' {0,1,2,3,4} @attribute 'Logged_income' REAL -@attribute 'Trips' {0,1,2,3,4,5,7} @data 19,1,2351.485149,170.4,0,0,0,7.762802386 From 90fe0b6a800afabbc8a4828f0e9a8f4fa60ca1e2 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Sat, 7 Sep 2019 14:44:57 -0400 Subject: [PATCH 2/2] Cleanups for DecisionTreeMainTest. --- .../tests/main_tests/decision_tree_test.cpp | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/mlpack/tests/main_tests/decision_tree_test.cpp b/src/mlpack/tests/main_tests/decision_tree_test.cpp index b770d333fd..ea7b10f139 100644 --- a/src/mlpack/tests/main_tests/decision_tree_test.cpp +++ b/src/mlpack/tests/main_tests/decision_tree_test.cpp @@ -261,6 +261,8 @@ BOOST_AUTO_TEST_CASE(DecisionRegularisationTest) mlpackMain(); pred = std::move(CLI::GetParam>("predictions")); + bindings::tests::CleanMemory(); + // Input training data. SetInputParam("training", std::make_tuple(info, inputData)); SetInputParam("labels", std::move(labels)); @@ -275,8 +277,8 @@ BOOST_AUTO_TEST_CASE(DecisionRegularisationTest) predRegularised = std::move(CLI::GetParam>("predictions")); size_t count = 0; - // This part of code is dupliacte with no weighted one. - for (size_t i = 0; i < 1000; ++i) + BOOST_REQUIRE_EQUAL(pred.n_elem, predRegularised.n_elem); + for (size_t i = 0; i < pred.n_elem; ++i) { if (pred[i] != predRegularised[i]) count++; @@ -377,9 +379,13 @@ BOOST_AUTO_TEST_CASE(DecisionTreeTrainingVerTest) mlpackMain(); + DecisionTreeModel* model = CLI::GetParam("output_model"); + CLI::GetParam("output_model") = NULL; + + bindings::tests::CleanMemory(); + // Input pre-trained model. - SetInputParam("input_model", - std::move(CLI::GetParam("output_model"))); + SetInputParam("input_model", model); Log::Fatal.ignoreInput = true; BOOST_REQUIRE_THROW(mlpackMain(), std::runtime_error); @@ -424,6 +430,11 @@ BOOST_AUTO_TEST_CASE(DecisionModelCategoricalReuseTest) predictions = std::move(CLI::GetParam>("predictions")); probabilities = std::move(CLI::GetParam("probabilities")); + DecisionTreeModel* model = CLI::GetParam("output_model"); + CLI::GetParam("output_model") = NULL; + + bindings::tests::CleanMemory(); + // Reset passed parameters. CLI::GetSingleton().Parameters()["training"].wasPassed = false; CLI::GetSingleton().Parameters()["labels"].wasPassed = false; @@ -432,8 +443,7 @@ BOOST_AUTO_TEST_CASE(DecisionModelCategoricalReuseTest) // Input trained model. SetInputParam("test", std::make_tuple(info, testData)); - SetInputParam("input_model", - std::move(CLI::GetParam("output_model"))); + SetInputParam("input_model", model); mlpackMain(); @@ -488,19 +498,21 @@ BOOST_AUTO_TEST_CASE(DecisionTreeMaximumDepthTest) // Check that number of output points are equal to number of input points. arma::Row predictions; - predictions = CLI::GetParam>("predictions"); + predictions = std::move(CLI::GetParam>("predictions")); - ResetDTSettings(); + bindings::tests::CleanMemory(); // Input training data. SetInputParam("training", std::make_tuple(info, inputData)); SetInputParam("labels", std::move(labels)); SetInputParam("weights", std::move(weights)); - SetInputParam("maximum_depth", (int) 4); + SetInputParam("maximum_depth", (int) 2); // Input test data. SetInputParam("test", std::make_tuple(info, testData)); + mlpackMain(); + CheckMatricesNotEqual(predictions, CLI::GetParam>("predictions")); }