[mlpack] 46/207: Ensure splits when only two points are in the set.

Barak A. Pearlmutter barak+git at pearlmutter.net
Thu Mar 23 17:53:39 UTC 2017


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch master
in repository mlpack.

commit 0141d5f5200687d0b668b8f5c06026f978a53618
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jan 23 13:22:16 2017 -0500

    Ensure splits when only two points are in the set.
    
    Previous to this change, when there were only two points in the set to be split,
    the loop to calculate gains would not be entered.  This commit fixes that by
    subtracting one from the upper bound of the loop.
---
 src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp b/src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp
index 7ec453f..b7d8e9a 100644
--- a/src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp
+++ b/src/mlpack/methods/decision_tree/best_binary_numeric_split_impl.hpp
@@ -36,7 +36,7 @@ double BestBinaryNumericSplit<FitnessFunction>::SplitIfBetter(
   // a minimum leaf size of 1 (empty children don't make sense).
   double bestFoundGain = bestGain;
   const size_t minimum = std::max(minimumLeafSize, (size_t) 1);
-  for (size_t index = minimum; index < data.n_elem - minimum; ++index)
+  for (size_t index = minimum; index < data.n_elem - (minimum - 1); ++index)
   {
     // Make sure that the value has changed.
     if (data[sortedIndices[index]] == data[sortedIndices[index - 1]])

-- 
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