[mlpack-git] master: Minor formatting change, and use zeros() instead of fill(). (dce0d32)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:58:01 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit dce0d32c9ff35fdb808e5d6cd1c3cd863e08307c
Author: Ryan Curtin <ryan at ratml.org>
Date: Sat Aug 16 18:34:46 2014 +0000
Minor formatting change, and use zeros() instead of fill().
>---------------------------------------------------------------
dce0d32c9ff35fdb808e5d6cd1c3cd863e08307c
src/mlpack/methods/adaboost/adaboost_impl.hpp | 44 ++++++++++++---------------
1 file changed, 19 insertions(+), 25 deletions(-)
diff --git a/src/mlpack/methods/adaboost/adaboost_impl.hpp b/src/mlpack/methods/adaboost/adaboost_impl.hpp
index 187ce2f..5902df6 100644
--- a/src/mlpack/methods/adaboost/adaboost_impl.hpp
+++ b/src/mlpack/methods/adaboost/adaboost_impl.hpp
@@ -207,50 +207,44 @@ AdaBoost<MatType, WeakLearner>::AdaBoost(
/**
*
*/
- template <typename MatType, typename WeakLearner>
- void AdaBoost<MatType, WeakLearner>::Classify(
- const MatType& test,
- arma::Row<size_t>& predictedLabels
- )
- {
+template <typename MatType, typename WeakLearner>
+void AdaBoost<MatType, WeakLearner>::Classify(
+ const MatType& test,
+ arma::Row<size_t>& predictedLabels)
+{
arma::Row<size_t> tempPredictedLabels(predictedLabels.n_cols);
arma::mat cMatrix(test.n_cols, numClasses);
- cMatrix.fill(0.0);
- predictedLabels.fill(0);
+ cMatrix.zeros();
+ predictedLabels.zeros();
- for(int i = 0;i < wl.size();i++)
+ for (int i = 0;i < wl.size(); i++)
{
- wl[i].Classify(test,tempPredictedLabels);
-
- for(int j = 0;j < tempPredictedLabels.n_cols; j++)
- {
- cMatrix(j,tempPredictedLabels(j)) += (alpha[i] * tempPredictedLabels(j));
- }
+ wl[i].Classify(test, tempPredictedLabels);
+ for (int j = 0; j < tempPredictedLabels.n_cols; j++)
+ cMatrix(j, tempPredictedLabels(j)) += (alpha[i] * tempPredictedLabels(j));
}
arma::rowvec cMRow;
arma::uword max_index;
- for(int i = 0;i < predictedLabels.n_cols;i++)
+ for (int i = 0; i < predictedLabels.n_cols; i++)
{
cMRow = cMatrix.row(i);
cMRow.max(max_index);
predictedLabels(i) = max_index;
}
-
- }
+}
/**
- * This function helps in building the Weight Distribution matrix
- * which is updated during every iteration. It calculates the
- * "difficulty" in classifying a point by adding the weights for all
- * instances, using D.
+ * This function helps in building the Weight Distribution matrix which is
+ * updated during every iteration. It calculates the "difficulty" in classifying
+ * a point by adding the weights for all instances, using D.
*
- * @param D The 2 Dimensional weight matrix from which the weights are
- * to be calculated.
- * @param weights The output weight vector.
+ * @param D The 2 Dimensional weight matrix from which the weights are
+ * to be calculated.
+ * @param weights The output weight vector.
*/
template <typename MatType, typename WeakLearner>
void AdaBoost<MatType, WeakLearner>::BuildWeightMatrix(
More information about the mlpack-git
mailing list