[mlpack] 45/207: Add tolerance for floating point errors.

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 7d7ef76eba923bbb4fdd8cae9d3e0d97615258a0
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jan 23 13:22:03 2017 -0500

    Add tolerance for floating point errors.
---
 src/mlpack/methods/decision_tree/all_categorical_split_impl.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/methods/decision_tree/all_categorical_split_impl.hpp b/src/mlpack/methods/decision_tree/all_categorical_split_impl.hpp
index 166f2de..48a8d26 100644
--- a/src/mlpack/methods/decision_tree/all_categorical_split_impl.hpp
+++ b/src/mlpack/methods/decision_tree/all_categorical_split_impl.hpp
@@ -24,6 +24,7 @@ double AllCategoricalSplit<FitnessFunction>::SplitIfBetter(
         /* aux */)
 {
   // Count the number of elements in each potential child.
+  const double epsilon = 1e-7; // Tolerance for floating-point errors.
   arma::Col<size_t> counts(numCategories);
   counts.zeros();
   for (size_t i = 0; i < data.n_elem; ++i)
@@ -59,7 +60,7 @@ double AllCategoricalSplit<FitnessFunction>::SplitIfBetter(
     overallGain += childPct * childGain;
   }
 
-  if (overallGain > bestGain)
+  if (overallGain > bestGain + epsilon)
   {
     // This is better, so set up the class probabilities vector and return.
     classProbabilities.set_size(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