[mlpack] 194/207: Fix test compilation.
Barak A. Pearlmutter
barak+git at pearlmutter.net
Thu Mar 23 17:53:53 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 e4551bf6500cd35bb34e1d5fb0f543048d11d2b1
Author: Ryan Curtin <ryan at ratml.org>
Date: Tue Mar 21 14:43:08 2017 -0400
Fix test compilation.
---
src/mlpack/tests/hoeffding_tree_test.cpp | 242 -------------------------------
src/mlpack/tests/load_save_test.cpp | 1 +
2 files changed, 1 insertion(+), 242 deletions(-)
diff --git a/src/mlpack/tests/hoeffding_tree_test.cpp b/src/mlpack/tests/hoeffding_tree_test.cpp
index 9712803..7039cf6 100644
--- a/src/mlpack/tests/hoeffding_tree_test.cpp
+++ b/src/mlpack/tests/hoeffding_tree_test.cpp
@@ -1145,246 +1145,4 @@ BOOST_AUTO_TEST_CASE(MultipleSerializationTest)
}
}
-// Test the Hoeffding tree model.
-BOOST_AUTO_TEST_CASE(HoeffdingTreeModelTest)
-{
- // Generate data.
- arma::mat dataset(4, 3000);
- arma::Row<size_t> labels(3000);
- data::DatasetInfo info(4); // All features are numeric, except the fourth.
- info.MapString<double>("0", 3);
- for (size_t i = 0; i < 3000; i += 3)
- {
- dataset(0, i) = mlpack::math::Random();
- dataset(1, i) = mlpack::math::Random();
- dataset(2, i) = mlpack::math::Random();
- dataset(3, i) = 0.0;
- labels[i] = 0;
-
- dataset(0, i + 1) = mlpack::math::Random();
- dataset(1, i + 1) = mlpack::math::Random() - 1.0;
- dataset(2, i + 1) = mlpack::math::Random() + 0.5;
- dataset(3, i + 1) = 0.0;
- labels[i + 1] = 2;
-
- dataset(0, i + 2) = mlpack::math::Random();
- dataset(1, i + 2) = mlpack::math::Random() + 1.0;
- dataset(2, i + 2) = mlpack::math::Random() + 0.8;
- dataset(3, i + 2) = 0.0;
- labels[i + 2] = 1;
- }
-
- // Train a model on a simple dataset, for all four types of models, and make
- // sure we get reasonable results.
- for (size_t i = 0; i < 4; ++i)
- {
- HoeffdingTreeModel m;
- switch (i)
- {
- case 0:
- m = HoeffdingTreeModel(HoeffdingTreeModel::GINI_HOEFFDING);
- break;
-
- case 1:
- m = HoeffdingTreeModel(HoeffdingTreeModel::GINI_BINARY);
- break;
-
- case 2:
- m = HoeffdingTreeModel(HoeffdingTreeModel::INFO_HOEFFDING);
- break;
-
- case 3:
- m = HoeffdingTreeModel(HoeffdingTreeModel::INFO_BINARY);
- break;
- }
-
- // We'll take 5 passes over the data.
- m.BuildModel(dataset, info, labels, 3, false, 0.99, 1000, 100, 100, 4, 100);
- for (size_t j = 0; j < 4; ++j)
- m.Train(dataset, labels, false);
-
- // Now make sure the performance is reasonable.
- arma::Row<size_t> predictions, predictions2;
- arma::rowvec probabilities;
- m.Classify(dataset, predictions);
- m.Classify(dataset, predictions2, probabilities);
-
- size_t correct = 0;
- for (size_t i = 0; i < 3000; ++i)
- {
- // Check consistency of predictions.
- BOOST_REQUIRE_EQUAL(predictions[i], predictions2[i]);
-
- if (labels[i] == predictions[i])
- ++correct;
- }
-
- // Require at least 95% accuracy.
- BOOST_REQUIRE_GT(correct, 2850);
- }
-}
-
-// Test the Hoeffding tree model in batch mode.
-BOOST_AUTO_TEST_CASE(HoeffdingTreeModelBatchTest)
-{
- // Generate data.
- arma::mat dataset(4, 3000);
- arma::Row<size_t> labels(3000);
- data::DatasetInfo info(4); // All features are numeric, except the fourth.
- info.MapString<double>("0", 3);
- for (size_t i = 0; i < 3000; i += 3)
- {
- dataset(0, i) = mlpack::math::Random();
- dataset(1, i) = mlpack::math::Random();
- dataset(2, i) = mlpack::math::Random();
- dataset(3, i) = 0.0;
- labels[i] = 0;
-
- dataset(0, i + 1) = mlpack::math::Random();
- dataset(1, i + 1) = mlpack::math::Random() - 1.0;
- dataset(2, i + 1) = mlpack::math::Random() + 0.5;
- dataset(3, i + 1) = 0.0;
- labels[i + 1] = 2;
-
- dataset(0, i + 2) = mlpack::math::Random();
- dataset(1, i + 2) = mlpack::math::Random() + 1.0;
- dataset(2, i + 2) = mlpack::math::Random() + 0.8;
- dataset(3, i + 2) = 0.0;
- labels[i + 2] = 1;
- }
-
- // Train a model on a simple dataset, for all four types of models, and make
- // sure we get reasonable results.
- for (size_t i = 0; i < 4; ++i)
- {
- HoeffdingTreeModel m;
- switch (i)
- {
- case 0:
- m = HoeffdingTreeModel(HoeffdingTreeModel::GINI_HOEFFDING);
- break;
-
- case 1:
- m = HoeffdingTreeModel(HoeffdingTreeModel::GINI_BINARY);
- break;
-
- case 2:
- m = HoeffdingTreeModel(HoeffdingTreeModel::INFO_HOEFFDING);
- break;
-
- case 3:
- m = HoeffdingTreeModel(HoeffdingTreeModel::INFO_BINARY);
- break;
- }
-
- // Train in batch.
- m.BuildModel(dataset, info, labels, 3, true, 0.99, 1000, 100, 100, 4, 100);
-
- // Now make sure the performance is reasonable.
- arma::Row<size_t> predictions, predictions2;
- arma::rowvec probabilities;
- m.Classify(dataset, predictions);
- m.Classify(dataset, predictions2, probabilities);
-
- size_t correct = 0;
- for (size_t i = 0; i < 3000; ++i)
- {
- // Check consistency of predictions.
- BOOST_REQUIRE_EQUAL(predictions[i], predictions2[i]);
-
- if (labels[i] == predictions[i])
- ++correct;
- }
-
- // Require at least 95% accuracy.
- BOOST_REQUIRE_GT(correct, 2850);
- }
-}
-
-BOOST_AUTO_TEST_CASE(HoeffdingTreeModelSerializationTest)
-{
- // Generate data.
- arma::mat dataset(4, 3000);
- arma::Row<size_t> labels(3000);
- data::DatasetInfo info(4); // All features are numeric, except the fourth.
- info.MapString<double>("0", 3);
- for (size_t i = 0; i < 3000; i += 3)
- {
- dataset(0, i) = mlpack::math::Random();
- dataset(1, i) = mlpack::math::Random();
- dataset(2, i) = mlpack::math::Random();
- dataset(3, i) = 0.0;
- labels[i] = 0;
-
- dataset(0, i + 1) = mlpack::math::Random();
- dataset(1, i + 1) = mlpack::math::Random() - 1.0;
- dataset(2, i + 1) = mlpack::math::Random() + 0.5;
- dataset(3, i + 1) = 0.0;
- labels[i + 1] = 2;
-
- dataset(0, i + 2) = mlpack::math::Random();
- dataset(1, i + 2) = mlpack::math::Random() + 1.0;
- dataset(2, i + 2) = mlpack::math::Random() + 0.8;
- dataset(3, i + 2) = 0.0;
- labels[i + 2] = 1;
- }
-
- // Train a model on a simple dataset, for all four types of models, and make
- // sure we get reasonable results.
- for (size_t i = 0; i < 4; ++i)
- {
- HoeffdingTreeModel m, xmlM, textM, binaryM;
- switch (i)
- {
- case 0:
- m = HoeffdingTreeModel(HoeffdingTreeModel::GINI_HOEFFDING);
- break;
-
- case 1:
- m = HoeffdingTreeModel(HoeffdingTreeModel::GINI_BINARY);
- break;
-
- case 2:
- m = HoeffdingTreeModel(HoeffdingTreeModel::INFO_HOEFFDING);
- break;
-
- case 3:
- m = HoeffdingTreeModel(HoeffdingTreeModel::INFO_BINARY);
- break;
- }
-
- // Train in batch.
- m.BuildModel(dataset, info, labels, 3, true, 0.99, 1000, 100, 100, 4, 100);
- // False training of XML model.
- xmlM.BuildModel(dataset, info, labels, 3, false, 0.5, 100, 100, 100, 2,
- 100);
-
- // Now make sure the performance is reasonable.
- arma::Row<size_t> predictions, predictionsXml, predictionsText,
- predictionsBinary;
- arma::rowvec probabilities, probabilitiesXml, probabilitiesText,
- probabilitiesBinary;
-
- SerializeObjectAll(m, xmlM, textM, binaryM);
-
- // Get predictions for all.
- m.Classify(dataset, predictions, probabilities);
- xmlM.Classify(dataset, predictionsXml, probabilitiesXml);
- textM.Classify(dataset, predictionsText, probabilitiesText);
- binaryM.Classify(dataset, predictionsBinary, probabilitiesBinary);
-
- for (size_t i = 0; i < 3000; ++i)
- {
- // Check consistency of predictions and probabilities.
- BOOST_REQUIRE_EQUAL(predictions[i], predictionsXml[i]);
- BOOST_REQUIRE_EQUAL(predictions[i], predictionsText[i]);
- BOOST_REQUIRE_EQUAL(predictions[i], predictionsBinary[i]);
-
- BOOST_REQUIRE_CLOSE(probabilities[i], probabilitiesXml[i], 1e-5);
- BOOST_REQUIRE_CLOSE(probabilities[i], probabilitiesText[i], 1e-5);
- BOOST_REQUIRE_CLOSE(probabilities[i], probabilitiesBinary[i], 1e-5);
- }
- }
-}
-
BOOST_AUTO_TEST_SUITE_END();
diff --git a/src/mlpack/tests/load_save_test.cpp b/src/mlpack/tests/load_save_test.cpp
index 1553179..b7cdc9e 100644
--- a/src/mlpack/tests/load_save_test.cpp
+++ b/src/mlpack/tests/load_save_test.cpp
@@ -13,6 +13,7 @@
#include <mlpack/core.hpp>
#include <mlpack/core/data/load_arff.hpp>
+#include <mlpack/core/data/load_impl.hpp>
#include <boost/test/unit_test.hpp>
#include "test_tools.hpp"
--
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