[mlpack-svn] r16705 - mlpack/trunk/src/mlpack/tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Jun 24 12:39:28 EDT 2014


Author: rcurtin
Date: Tue Jun 24 12:39:28 2014
New Revision: 16705

Log:
Minor changes to test.  const-correctness and comment normalization for Doxygen.


Modified:
   mlpack/trunk/src/mlpack/tests/decision_stump_test.cpp

Modified: mlpack/trunk/src/mlpack/tests/decision_stump_test.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/tests/decision_stump_test.cpp	(original)
+++ mlpack/trunk/src/mlpack/tests/decision_stump_test.cpp	Tue Jun 24 12:39:28 2014
@@ -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::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 @@
   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 @@
   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 @@
   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 @@
   data::Save(output, predictedLabels, true, true);
 }
 
-BOOST_AUTO_TEST_SUITE_END();
\ No newline at end of file
+BOOST_AUTO_TEST_SUITE_END();



More information about the mlpack-svn mailing list