[mlpack-git] master: Fix error in MinimalSplitsNumberSweep with casting negative numbers to size_t. (c2d7a55)
gitdub at mlpack.org
gitdub at mlpack.org
Wed Jun 29 07:35:33 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/6147ed01bab6eadcd6a5e796e259a6afacae4662...e0fd69006b17a845f066ea4de1e205fc0922739d
>---------------------------------------------------------------
commit c2d7a5543a848a4db8473964d0d0b3b05036fb0e
Author: Mikhail Lozhnikov <lozhnikovma at gmail.com>
Date: Wed Jun 29 14:35:33 2016 +0300
Fix error in MinimalSplitsNumberSweep with casting negative numbers to size_t.
>---------------------------------------------------------------
c2d7a5543a848a4db8473964d0d0b3b05036fb0e
.../tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp b/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp
index 6328abb..7f63568 100644
--- a/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/minimal_splits_number_sweep_impl.hpp
@@ -64,7 +64,14 @@ size_t MinimalSplitsNumberSweep<SplitPolicy>::SweepNonLeafNode(
numTreeTwoChildren <= node->MaxNumChildren() && numTreeTwoChildren > 0)
{
// Evaluate the cost using the number of splits and balancing.
- size_t cost = numSplits * (std::abs(sorted.size() / 2 - i));
+ size_t balance;
+
+ if (sorted.size() / 2 > i )
+ balance = sorted.size() / 2 - i;
+ else
+ balance = i - sorted.size() / 2;
+
+ size_t cost = numSplits * balance;
if (cost < minCost)
{
minCost = cost;
More information about the mlpack-git
mailing list