[mlpack-git] master: Add a test for the ARFF reader. (6d96f3a)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Dec 23 11:44:49 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/de9cc4b05069e1fa4793d9355f2f595af5ff45d2...6070527af14296cd99739de6c62666cc5d2a2125

>---------------------------------------------------------------

commit 6d96f3a73abfd290daa601bbbdf66fe2aa95d251
Author: ryan <ryan at ratml.org>
Date:   Tue Oct 20 17:50:58 2015 -0400

    Add a test for the ARFF reader.
    
    I have two more tests planned...


>---------------------------------------------------------------

6d96f3a73abfd290daa601bbbdf66fe2aa95d251
 src/mlpack/tests/load_save_test.cpp | 52 +++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/src/mlpack/tests/load_save_test.cpp b/src/mlpack/tests/load_save_test.cpp
index 68adc85..60af90b 100644
--- a/src/mlpack/tests/load_save_test.cpp
+++ b/src/mlpack/tests/load_save_test.cpp
@@ -1093,4 +1093,56 @@ BOOST_AUTO_TEST_CASE(CategoricalNontransposedCSVLoadTest)
   remove("test.csv");
 }
 
+/**
+ * A simple ARFF load test.  Two attributes, both numeric.
+ */
+BOOST_AUTO_TEST_CASE(SimpleARFFTest)
+{
+  fstream f;
+  f.open("test.arff", fstream::out);
+  f << "@relation test" << endl;
+  f << endl;
+  f << "@attribute one NUMERIC" << endl;
+  f << "@attribute two NUMERIC" << endl;
+  f << endl;
+  f << "@data" << endl;
+  f << "1, 2" << endl;
+  f << "3, 4" << endl;
+  f << "5, 6" << endl;
+  f << "7, 8" << endl;
+  f.close();
+
+  arma::mat dataset;
+  DatasetInfo info;
+  data::Load("test.arff", dataset, info);
+
+  BOOST_REQUIRE_EQUAL(info.Dimensionality(), 2);
+  BOOST_REQUIRE(info.Type(0) == Datatype::numeric);
+  BOOST_REQUIRE(info.Type(1) == Datatype::numeric);
+
+  BOOST_REQUIRE_EQUAL(dataset.n_rows, 2);
+  BOOST_REQUIRE_EQUAL(dataset.n_cols, 4);
+
+  for (size_t i = 0; i < 8; ++i)
+    BOOST_REQUIRE_CLOSE(dataset[i], double(i + 1), 1e-5);
+}
+
+/**
+ * Another simple ARFF load test.  Three attributes, two categorical, one
+ * numeric.
+ */
+BOOST_AUTO_TEST_CASE(SimpleARFFCategoricalTest)
+{
+
+}
+
+/**
+ * A harder ARFF test, where we have each type of supported value, and some
+ * random whitespace too.
+ */
+BOOST_AUTO_TEST_CASE(HarderARFFTest)
+{
+
+}
+
 BOOST_AUTO_TEST_SUITE_END();



More information about the mlpack-git mailing list