[mlpack] 74/324: Minor changes to test. const-correctness and comment normalization for Doxygen.
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Sun Aug 17 08:21:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch svn-trunk
in repository mlpack.
commit 94170893bec87755612b26375b2a14968abf5996
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Tue Jun 24 16:39:28 2014 +0000
Minor changes to test. const-correctness and comment normalization for Doxygen.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16705 9d5b8971-822b-0410-80eb-d18c1038ef23
---
src/mlpack/tests/decision_stump_test.cpp | 135 +++++++++++++++----------------
1 file changed, 67 insertions(+), 68 deletions(-)
diff --git a/src/mlpack/tests/decision_stump_test.cpp b/src/mlpack/tests/decision_stump_test.cpp
index 840b6f7..c826295 100644
--- a/src/mlpack/tests/decision_stump_test.cpp
+++ b/src/mlpack/tests/decision_stump_test.cpp
@@ -1,10 +1,9 @@
-/*
- * @file decision_stump_test.cpp
- * @author Udit Saxena
- *
- * Test for Decision Stump
+/**
+ * @file decision_stump_test.cpp
+ * @author Udit Saxena
+ *
+ * Tests for DecisionStump class.
*/
-
#include <mlpack/core.hpp>
#include <mlpack/methods/decision_stump/decision_stump.hpp>
@@ -15,62 +14,62 @@ using namespace mlpack;
using namespace mlpack::decision_stump;
using namespace arma;
-BOOST_AUTO_TEST_SUITE(DSTEST);
+BOOST_AUTO_TEST_SUITE(DecisionStumpTest);
-/*
-This tests handles the case wherein only one class exists in the input labels.
-It checks whether the only class supplied was the only class predicted.
+/**
+ * This tests handles the case wherein only one class exists in the input
+ * labels. It checks whether the only class supplied was the only class
+ * predicted.
*/
BOOST_AUTO_TEST_CASE(OneClass)
{
- size_t numClasses = 2;
- size_t inpBucketSize = 6;
+ const size_t numClasses = 2;
+ const size_t inpBucketSize = 6;
mat trainingData;
trainingData << 2.4 << 3.8 << 3.8 << endr
- << 1 << 1 << 2 << endr
+ << 1 << 1 << 2 << endr
<< 1.3 << 1.9 << 1.3 << endr;
-
+
+ // No need to normalize labels here.
Mat<size_t> labelsIn;
labelsIn << 1 << 1 << 1;
-
- // no need to normalize labels here.
mat testingData;
testingData << 2.4 << 2.5 << 2.6;
-
+
DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize);
Row<size_t> predictedLabels(testingData.n_cols);
ds.Classify(testingData, predictedLabels);
- for(size_t i = 0; i < predictedLabels.size(); i++ )
- BOOST_CHECK_EQUAL(predictedLabels(i),1);
+ for (size_t i = 0; i < predictedLabels.size(); i++ )
+ BOOST_CHECK_EQUAL(predictedLabels(i), 1);
-}
+}
-/*
-This tests for the classification:
- if testinput < 0 - class 0
- if testinput > 0 - class 1
-An almost perfect split on zero.
-*/
+/**
+ * This tests for the classification:
+ * if testinput < 0 - class 0
+ * if testinput > 0 - class 1
+ * An almost perfect split on zero.
+ */
BOOST_AUTO_TEST_CASE(PerfectSplitOnZero)
{
- size_t numClasses = 2;
+ const size_t numClasses = 2;
const char* output = "outputPerfectSplitOnZero.csv";
- size_t inpBucketSize = 2;
+ const size_t inpBucketSize = 2;
mat trainingData;
trainingData << -1 << 1 << -2 << 2 << -3 << 3;
-
+
+ // No need to normalize labels here.
Mat<size_t> labelsIn;
labelsIn << 0 << 1 << 0 << 1 << 0 << 1;
- // no need to normalize labels here.
mat testingData;
testingData << -4 << 7 << -7 << -5 << 6;
-
+
DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize);
Row<size_t> predictedLabels(testingData.n_cols);
@@ -79,27 +78,26 @@ BOOST_AUTO_TEST_CASE(PerfectSplitOnZero)
data::Save(output, predictedLabels, true, true);
}
-/*
-This tests the binning function for the case when a dataset with
-cardinality of input < inpBucketSize is provided.
-*/
+/**
+ * This tests the binning function for the case when a dataset with cardinality
+ * of input < inpBucketSize is provided.
+ */
BOOST_AUTO_TEST_CASE(BinningTesting)
{
- size_t numClasses = 2;
+ const size_t numClasses = 2;
const char* output = "outputBinningTesting.csv";
- size_t inpBucketSize = 10;
+ const size_t inpBucketSize = 10;
mat trainingData;
trainingData << -1 << 1 << -2 << 2 << -3 << 3 << -4;
-
+
+ // No need to normalize labels here.
Mat<size_t> labelsIn;
labelsIn << 0 << 1 << 0 << 1 << 0 << 1 << 0;
-
- // no need to normalize labels here.
mat testingData;
testingData << 5;
-
+
DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize);
Row<size_t> predictedLabels(testingData.n_cols);
@@ -108,29 +106,29 @@ BOOST_AUTO_TEST_CASE(BinningTesting)
data::Save(output, predictedLabels, true, true);
}
-/*
-This is a test for the case when non-overlapping, multiple
-classes are provided. It tests for a perfect split due to the
-non-overlapping nature of the input classes.
-*/
+/**
+ * This is a test for the case when non-overlapping, multiple classes are
+ * provided. It tests for a perfect split due to the non-overlapping nature of
+ * the input classes.
+ */
BOOST_AUTO_TEST_CASE(PerfectMultiClassSplit)
{
- size_t numClasses = 4;
+ const size_t numClasses = 4;
const char* output = "outputPerfectMultiClassSplit.csv";
- size_t inpBucketSize = 3;
+ const size_t inpBucketSize = 3;
mat trainingData;
trainingData << -8 << -7 << -6 << -5 << -4 << -3 << -2 << -1
- << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7;
-
+ << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7;
+
+ // No need to normalize labels here.
Mat<size_t> labelsIn;
- labelsIn << 0 << 0 << 0 << 0 << 1 << 1 << 1 << 1
+ labelsIn << 0 << 0 << 0 << 0 << 1 << 1 << 1 << 1
<< 2 << 2 << 2 << 2 << 3 << 3 << 3 << 3;
- // no need to normalize labels here.
mat testingData;
testingData << -6.1 << -2.1 << 1.1 << 5.1;
-
+
DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize);
Row<size_t> predictedLabels(testingData.n_cols);
@@ -139,30 +137,31 @@ BOOST_AUTO_TEST_CASE(PerfectMultiClassSplit)
data::Save(output, predictedLabels, true, true);
}
-/*
-This test is for the case when reasonably overlapping, multiple classes
-are provided in the input label set. It tests whether classification
-takes place with a reasonable amount of error due to the overlapping
-nature of input classes.
-*/
+/**
+ * This test is for the case when reasonably overlapping, multiple classes are
+ * provided in the input label set. It tests whether classification takes place
+ * with a reasonable amount of error due to the overlapping nature of input
+ * classes.
+ */
BOOST_AUTO_TEST_CASE(MultiClassSplit)
{
- size_t numClasses = 3;
+ const size_t numClasses = 3;
const char* output = "outputMultiClassSplit.csv";
- size_t inpBucketSize = 3;
+ const size_t inpBucketSize = 3;
mat trainingData;
- trainingData << -7 << -6 << -5 << -4 << -3 << -2 << -1 << 0 << 1
- << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10;
-
+ trainingData << -7 << -6 << -5 << -4 << -3 << -2 << -1 << 0 << 1
+ << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10;
+
+ // No need to normalize labels here.
Mat<size_t> labelsIn;
- labelsIn << 0 << 0 << 0 << 0 << 1 << 1 << 0 << 0
+ labelsIn << 0 << 0 << 0 << 0 << 1 << 1 << 0 << 0
<< 1 << 1 << 1 << 2 << 1 << 2 << 2 << 2 << 2 << 2;
- // no need to normalize labels here.
+
mat testingData;
testingData << -6.1 << -5.9 << -2.1 << -0.7 << 2.5 << 4.7 << 7.2 << 9.1;
-
+
DecisionStump<> ds(trainingData, labelsIn.row(0), numClasses, inpBucketSize);
Row<size_t> predictedLabels(testingData.n_cols);
@@ -171,4 +170,4 @@ BOOST_AUTO_TEST_CASE(MultiClassSplit)
data::Save(output, predictedLabels, true, true);
}
-BOOST_AUTO_TEST_SUITE_END();
\ No newline at end of file
+BOOST_AUTO_TEST_SUITE_END();
--
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