[mlpack] 76/324: Use const double where possible instead of having a variable used throughout the function. This is only for clarity and consistency and is not likely to make any runtime difference.
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Sun Aug 17 08:21:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch svn-trunk
in repository mlpack.
commit 47402ce986ac97297f3c814fe57d224230f990d3
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Tue Jun 24 23:29:08 2014 +0000
Use const double where possible instead of having a variable used throughout the
function. This is only for clarity and consistency and is not likely to make
any runtime difference.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16707 9d5b8971-822b-0410-80eb-d18c1038ef23
---
.../methods/decision_stump/decision_stump_impl.hpp | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/src/mlpack/methods/decision_stump/decision_stump_impl.hpp b/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
index 9c387c7..2c757ca 100644
--- a/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
+++ b/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
@@ -38,7 +38,7 @@ DecisionStump<MatType>::DecisionStump(const MatType& data,
numClass = classes;
bucketSize = inpBucketSize;
- /* Check whether the input labels are not all identical. */
+ // Check whether the input labels are not all identical.
if (!isDistinct<size_t>(classLabels))
{
// If the classLabels are all identical, the default class is the only
@@ -46,7 +46,6 @@ DecisionStump<MatType>::DecisionStump(const MatType& data,
oneClass = true;
defaultClass = classLabels(0);
}
-
else
{
// If classLabels are not all identical, proceed with training.
@@ -96,34 +95,31 @@ template<typename MatType>
void DecisionStump<MatType>::Classify(const MatType& test,
arma::Row<size_t>& predictedLabels)
{
- bool flag;
- double val;
if (!oneClass)
{
for (int i = 0; i < test.n_cols; i++)
{
int j = 0;
- flag = false;
- val = test(splitCol,i);
- while ((j < split.n_rows) && (!flag))
+ const double val = test(splitCol, i);
+ while (j < split.n_rows)
{
if (val < split(j, 0) && (!j))
{
predictedLabels(i) = split(0, 1);
- flag = true;
+ break;
}
else if (val >= split(j, 0))
{
if (j == split.n_rows - 1)
{
predictedLabels(i) = split(split.n_rows - 1, 1);
- flag = true;
+ break;
}
else if (val < split(j + 1, 0))
{
predictedLabels(i) = split(j, 1);
- flag = true;
+ break;
}
}
j++;
@@ -392,7 +388,7 @@ int DecisionStump<MatType>::isDistinct(const arma::Row<rType>& featureRow)
}
/**
- * Calculating Entropy of attribute.
+ * Calculate entropy of attribute.
*
* @param attribute The attribute for which we calculate the entropy.
* @param labels Corresponding labels of the attribute.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list