[mlpack-svn] r17096 - in mlpack/trunk/src/mlpack: methods/adaboost tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Aug 22 00:53:14 EDT 2014
Author: saxena.udit
Date: Fri Aug 22 00:53:14 2014
New Revision: 17096
Log:
Style changes. No code changes
Modified:
mlpack/trunk/src/mlpack/methods/adaboost/adaboost.hpp
mlpack/trunk/src/mlpack/methods/adaboost/adaboost_impl.hpp
mlpack/trunk/src/mlpack/methods/adaboost/adaboost_main.cpp
mlpack/trunk/src/mlpack/tests/adaboost_test.cpp
Modified: mlpack/trunk/src/mlpack/methods/adaboost/adaboost.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/adaboost/adaboost.hpp (original)
+++ mlpack/trunk/src/mlpack/methods/adaboost/adaboost.hpp Fri Aug 22 00:53:14 2014
@@ -59,6 +59,12 @@
// The tolerance for change in rt and when to stop.
double tolerance;
+ /**
+ * Classification Function.
+ * @param test Testing data.
+ * @param predictedLabels Vector to store the predicted labels of the
+ * test set.
+ */
void Classify(const MatType& test, arma::Row<size_t>& predictedLabels);
private:
Modified: mlpack/trunk/src/mlpack/methods/adaboost/adaboost_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/adaboost/adaboost_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/methods/adaboost/adaboost_impl.hpp Fri Aug 22 00:53:14 2014
@@ -47,8 +47,7 @@
tolerance = tol;
double rt, crt, alphat = 0.0, zt;
- // double tolerance = 1e-8;
- // std::cout<<"Tolerance is "<<tolerance<<"\n";
+
// crt is for stopping the iterations when rt
// stops changing by less than a tolerant value.
@@ -56,7 +55,6 @@
// stops changing by less than a tolerant value.
ztProduct = 1.0;
- // ztAccumulator is
// To be used for prediction by the Weak Learner for prediction.
arma::Row<size_t> predictedLabels(labels.n_cols);
@@ -83,7 +81,6 @@
// now start the boosting rounds
for (int i = 0; i < iterations; i++)
{
- // std::cout<<"Run "<<i<<" times.\n";
// Initialized to zero in every round.
// rt is used for calculation of alphat, is the weighted error
// rt = (sum)D(i)y(i)ht(xi)
@@ -95,12 +92,11 @@
// Build the weight vectors
BuildWeightMatrix(D, weights);
- // std::cout<<"Just about to call the weak leaerner. \n";
// call the other weak learner and train the labels.
WeakLearner w(other, tempData, weights, labels);
w.Classify(tempData, predictedLabels);
- //Now from predictedLabels, build ht, the weak hypothesis
+ // Now from predictedLabels, build ht, the weak hypothesis
// buildClassificationMatrix(ht, predictedLabels);
// Now, start calculation of alpha(t) using ht
@@ -122,8 +118,6 @@
}
}
// end calculation of rt
- // std::cout<<"Value of rt is: "<<rt<<"\n";
-
if (i > 0)
{
@@ -187,7 +181,6 @@
// Iterations are over, now build a strong hypothesis
// from a weighted combination of these weak hypotheses.
- // std::cout<<"Just about to look at the final hypo.\n";
arma::colvec tempSumFinalH;
arma::uword max_index;
arma::mat sfh = sumFinalH.t();
@@ -202,7 +195,10 @@
}
/**
- *
+ * Classification Function.
+ * @param test Testing data.
+ * @param predictedLabels Vector to store the predicted labels of the
+ * test set.
*/
template <typename MatType, typename WeakLearner>
void AdaBoost<MatType, WeakLearner>::Classify(
@@ -222,7 +218,7 @@
for (int j = 0; j < tempPredictedLabels.n_cols; j++)
cMatrix(tempPredictedLabels(j), j) += (alpha[i] * tempPredictedLabels(j));
}
- // std::cout<<"Not working here ?\n";
+
arma::colvec cMRow;
arma::uword max_index;
@@ -258,15 +254,6 @@
}
}
-/*/**
- * Return the value of ztProduct
- */
- /*
-template <typename MatType, typename WeakLearner>
-double GetztProduct()
-{
- return ztProduct;
-}*/
} // namespace adaboost
} // namespace mlpack
Modified: mlpack/trunk/src/mlpack/methods/adaboost/adaboost_main.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/adaboost/adaboost_main.cpp (original)
+++ mlpack/trunk/src/mlpack/methods/adaboost/adaboost_main.cpp Fri Aug 22 00:53:14 2014
@@ -64,7 +64,6 @@
" will be written.", "o", "output.csv");
PARAM_INT("iterations","The maximum number of boosting iterations "
"to be run", "i", 1000);
-// PARAM_INT("classes","The number of classes in the input label set.","c");
PARAM_DOUBLE("tolerance","The tolerance for change in values of rt","e",1e-10);
int main(int argc, char *argv[])
Modified: mlpack/trunk/src/mlpack/tests/adaboost_test.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/tests/adaboost_test.cpp (original)
+++ mlpack/trunk/src/mlpack/tests/adaboost_test.cpp Fri Aug 22 00:53:14 2014
@@ -573,9 +573,7 @@
/**
* This test case runs the AdaBoost.mh algorithm on the UCI Vertebral
* Column dataset.
- * It tests the Classify function and checks if the error returned by
- * running the boosted weak learner using adaboost is comparable to the
- * error returned by running Classify() on the same function.
+ * It tests the Classify function and checks for a satisfiable error rate.
*/
BOOST_AUTO_TEST_CASE(ClassifyTest_VERTEBRALCOL)
{
@@ -620,9 +618,7 @@
/**
* This test case runs the AdaBoost.mh algorithm on a non linearly
* separable dataset.
- * It tests the Classify function and checks if the error returned by
- * running the boosted weak learner using adaboost is comparable to the
- * error returned by running Classify() on the same function.
+ * It tests the Classify function and checks for a satisfiable error rate.
*/
BOOST_AUTO_TEST_CASE(ClassifyTest_NONLINSEP)
{
@@ -667,6 +663,12 @@
BOOST_REQUIRE(lError <= 0.30);
}
+/**
+ * This test case runs the AdaBoost.mh algorithm on the UCI Iris Dataset.
+ * It trains it on two thirds of the Iris dataset (iris_train.csv),
+ * and tests on the remaining third of the dataset (iris_test.csv).
+ * It tests the Classify function and checks for a satisfiable error rate.
+ */
BOOST_AUTO_TEST_CASE(ClassifyTest_IRIS)
{
arma::mat inputData;
More information about the mlpack-svn
mailing list