[mlpack-git] master: Minor code cleanups. (2886b9f)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:55:46 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 2886b9fd2d46428a01d474d2d7221e65956f9658
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Aug 4 15:18:30 2014 +0000

    Minor code cleanups.


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

2886b9fd2d46428a01d474d2d7221e65956f9658
 .../methods/decision_stump/decision_stump.hpp      | 33 +++++++++++-----------
 .../methods/decision_stump/decision_stump_impl.hpp | 26 ++++++++---------
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/src/mlpack/methods/decision_stump/decision_stump.hpp b/src/mlpack/methods/decision_stump/decision_stump.hpp
index d4a7235..895fd4a 100644
--- a/src/mlpack/methods/decision_stump/decision_stump.hpp
+++ b/src/mlpack/methods/decision_stump/decision_stump.hpp
@@ -54,22 +54,20 @@ class DecisionStump
   void Classify(const MatType& test, arma::Row<size_t>& predictedLabels);
 
   /**
-   *  Alternate constructor which copies parameters bucketSize and numClass
-   *  from an already initiated decision stump, other. It appropriately 
-   *  sets the Weight vector.
+   * Alternate constructor which copies parameters bucketSize and numClass from
+   * an already initiated decision stump, other. It appropriately sets the
+   * weight vector.
    *
-   *  @param other The other initiated Decision Stump object from 
-   *               which we copy the values from.
-   *  @param data The data on which to train this object on.
-   *  @param D Weight vector to use while training. For boosting purposes.
-   *  @param labels The labels of data.
+   * @param other The other initiated Decision Stump object from
+   *      which we copy the values from.
+   * @param data The data on which to train this object on.
+   * @param D Weight vector to use while training. For boosting purposes.
+   * @param labels The labels of data.
    */
-  DecisionStump(
-    const DecisionStump<>& other, 
-    const MatType& data, 
-    const arma::rowvec& weights, 
-    const arma::Row<size_t>& labels
-    );
+  DecisionStump(const DecisionStump<>& other,
+                const MatType& data,
+                const arma::rowvec& weights,
+                const arma::Row<size_t>& labels);
 
   //! Access the splitting attribute.
   int SplitAttribute() const { return splitAttribute; }
@@ -134,7 +132,8 @@ class DecisionStump
    * @param subCols The vector in which to find the most frequently
    *     occurring element.
    */
-  template <typename rType> rType CountMostFreq(const arma::Row<rType>& subCols);
+  template <typename rType> rType CountMostFreq(const arma::Row<rType>&
+      subCols);
 
   /**
    * Returns 1 if all the values of featureRow are not same.
@@ -153,8 +152,10 @@ class DecisionStump
   double CalculateEntropy(arma::subview_row<LabelType> labels, int begin);
 
   /**
+   * Train the decision stump on the given data and labels.
    *
-   *
+   * @param data Dataset to train on.
+   * @param labels Labels for dataset.
    */
   void Train(const MatType& data, const arma::Row<size_t>& labels);
 
diff --git a/src/mlpack/methods/decision_stump/decision_stump_impl.hpp b/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
index 419abae..ee095ff 100644
--- a/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
+++ b/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
@@ -60,7 +60,6 @@ void DecisionStump<MatType>::Train(const MatType& data, const arma::Row<size_t>&
       // splitting attribute and calculate entropy if split on it.
       entropy = SetupSplitAttribute(data.row(i), labels);
 
-      // Log::Debug << "Entropy for attribute " << i << " is " << entropy << ".\n";
       gain = rootEntropy - entropy;
       // Find the attribute with the best entropy so that the gain is
       // maximized.
@@ -114,15 +113,15 @@ void DecisionStump<MatType>::Classify(const MatType& test,
 }
 
 /**
- *  Alternate constructor which copies parameters bucketSize and numClass
- *  from an already initiated decision stump, other. It appropriately 
- *  sets the Weight vector.
+ * Alternate constructor which copies parameters bucketSize and numClass
+ * from an already initiated decision stump, other. It appropriately
+ * sets the Weight vector.
  *
- *  @param other The other initiated Decision Stump object from 
- *               which we copy the values from.
- *  @param data The data on which to train this object on.
- *  @param D Weight vector to use while training. For boosting purposes.
- *  @param labels The labels of data.
+ * @param other The other initiated Decision Stump object from
+ *      which we copy the values from.
+ * @param data The data on which to train this object on.
+ * @param D Weight vector to use while training. For boosting purposes.
+ * @param labels The labels of data.
  */
 template <typename MatType>
 DecisionStump<MatType>::DecisionStump(
@@ -411,7 +410,9 @@ int DecisionStump<MatType>::IsDistinct(const arma::Row<rType>& featureRow)
  */
 template<typename MatType>
 template<typename LabelType>
-double DecisionStump<MatType>::CalculateEntropy(arma::subview_row<LabelType> labels, int begin)
+double DecisionStump<MatType>::CalculateEntropy(
+    arma::subview_row<LabelType> labels,
+    int begin)
 {
   double entropy = 0.0;
   size_t j;
@@ -419,10 +420,9 @@ double DecisionStump<MatType>::CalculateEntropy(arma::subview_row<LabelType> lab
   arma::Row<size_t> numElem(numClass);
   numElem.fill(0);
 
-  // variable to accumulate the weight in this subview_row
+  // Variable to accumulate the weight in this subview_row.
   double accWeight = 0.0;
-  // Populate numElem; they are used as helpers to calculate
-  // entropy.
+  // Populate numElem; they are used as helpers to calculate entropy.
 
   for (j = 0; j < labels.n_elem; j++)
   {



More information about the mlpack-git mailing list