[mlpack-git] master: Fix bug that could cause a hang. (b48e9a9)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Wed Dec 23 11:45:06 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/de9cc4b05069e1fa4793d9355f2f595af5ff45d2...6070527af14296cd99739de6c62666cc5d2a2125

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

commit b48e9a95c4529a092f716316512d4a325a59727b
Author: ryan <ryan at ratml.org>
Date:   Thu Oct 22 12:43:35 2015 -0400

    Fix bug that could cause a hang.
    
    Basically, the loop could iterate past the end of the map.  This only happened
    with less than 1000 elements on my machine (specifically, the 1000 was a cut-off
    point: 1000 worked, 999 didn't), on the covertype dataset.  I'm still not 100%
    sure why 1000 was a magical cutoff point, but, this fixes the issue...


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

b48e9a95c4529a092f716316512d4a325a59727b
 src/mlpack/methods/hoeffding_trees/binary_numeric_split_impl.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mlpack/methods/hoeffding_trees/binary_numeric_split_impl.hpp b/src/mlpack/methods/hoeffding_trees/binary_numeric_split_impl.hpp
index 776aa8d..3c43b23 100644
--- a/src/mlpack/methods/hoeffding_trees/binary_numeric_split_impl.hpp
+++ b/src/mlpack/methods/hoeffding_trees/binary_numeric_split_impl.hpp
@@ -59,7 +59,7 @@ double BinaryNumericSplit<FitnessFunction, ObservationType>::
     ++counts((*it).second, 0);
 
     // TODO: skip ahead if the next value is the same.
-    double value = FitnessFunction::Evaluate(counts);
+    const double value = FitnessFunction::Evaluate(counts);
     if (value > bestValue)
     {
       bestValue = value;
@@ -87,7 +87,7 @@ void BinaryNumericSplit<FitnessFunction, ObservationType>::Split(
   counts.col(1) = classCounts;
 
   for (typename std::multimap<ObservationType, size_t>::const_iterator it =
-      sortedElements.begin(); (*it).first <= bestSplit; ++it)
+      sortedElements.begin(); (*it).first < bestSplit; ++it)
   {
     // Move the point to the correct side of the split.
     --counts((*it).second, 1);



More information about the mlpack-git mailing list