[mlpack-svn] r17129 - mlpack/tags/mlpack-1.0.10/src/mlpack/methods/decision_stump
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Aug 29 10:40:20 EDT 2014
Author: rcurtin
Date: Fri Aug 29 10:40:20 2014
New Revision: 17129
Log:
Fix usage of log2(), which does not exist in C99.
Modified:
mlpack/tags/mlpack-1.0.10/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
Modified: mlpack/tags/mlpack-1.0.10/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.10/src/mlpack/methods/decision_stump/decision_stump_impl.hpp (original)
+++ mlpack/tags/mlpack-1.0.10/src/mlpack/methods/decision_stump/decision_stump_impl.hpp Fri Aug 29 10:40:20 2014
@@ -428,14 +428,17 @@
for (j = 0; j < labels.n_elem; j++)
numElem(labels(j))++;
+ // The equation for entropy uses log2(), but log2() is from C99 and thus
+ // Visual Studio will not have it. Therefore, we will use std::log(), and
+ // then apply the change-of-base formula at the end of the calculation.
for (j = 0; j < numClass; j++)
{
const double p1 = ((double) numElem(j) / labels.n_elem);
- entropy += (p1 == 0) ? 0 : p1 * log2(p1);
+ entropy += (p1 == 0) ? 0 : p1 * std::log(p1);
}
- return entropy;
+ return entropy / std::log(2.0);
}
}; // namespace decision_stump
More information about the mlpack-svn
mailing list