[mlpack-svn] r16701 - mlpack/trunk/src/mlpack/methods/decision_stump

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Jun 24 01:23:01 EDT 2014


Author: rcurtin
Date: Tue Jun 24 01:23:01 2014
New Revision: 16701

Log:
Use bool instead of int.


Modified:
   mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump.hpp
   mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump_impl.hpp

Modified: mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump.hpp	Tue Jun 24 01:23:01 2014
@@ -56,7 +56,7 @@
   int splitCol;
 
   //! Flag value for distinct input class labels.
-  int oneClass;
+  bool oneClass;
 
   //! Size of bucket while determining splitting criterion.
   size_t bucketSize;

Modified: mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/decision_stump/decision_stump_impl.hpp	Tue Jun 24 01:23:01 2014
@@ -43,14 +43,14 @@
   {
     // If the classLabels are all identical, the default class is the only
     // class.
-    oneClass = 1;
+    oneClass = true;
     defaultClass = classLabels(0);
   }
 
   else
   {
     // If classLabels are not all identical, proceed with training.
-    oneClass = 0;
+    oneClass = false;
     int bestAtt = -1;
     double entropy;
     double bestEntropy = DBL_MAX;
@@ -96,14 +96,14 @@
 void DecisionStump<MatType>::Classify(const MatType& test,
                                       arma::Row<size_t>& predictedLabels)
 {
-  int flag;
+  bool flag;
   double val;
   if (!oneClass)
   {
     for (int i = 0; i < test.n_cols; i++)
     {
       int j = 0;
-      flag = 0;
+      flag = false;
 
       val = test(splitCol,i);
       while ((j < split.n_rows) && (!flag))
@@ -111,19 +111,19 @@
         if (val < split(j, 0) && (!j))
         {
           predictedLabels(i) = split(0, 1);
-          flag = 1;
+          flag = true;
         }
         else if (val >= split(j, 0))
         {
           if (j == split.n_rows - 1)
           {
             predictedLabels(i) = split(split.n_rows - 1, 1);
-            flag = 1;
+            flag = true;
           }
           else if (val < split(j + 1, 0))
           {
             predictedLabels(i) = split(j, 1);
-            flag = 1;
+            flag = true;
           }
         }
         j++;



More information about the mlpack-svn mailing list