[mlpack-git] master: This wasn't actually mean split before. Now it is. (076156d)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Sun May 3 19:34:32 EDT 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/174d2de995a3fe343cd92d158730f3afa03e622d...076156df78e26ba87012f2b5fbc6d45e84da918b

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

commit 076156df78e26ba87012f2b5fbc6d45e84da918b
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sun May 3 19:34:14 2015 -0400

    This wasn't actually mean split before.  Now it is.


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

076156df78e26ba87012f2b5fbc6d45e84da918b
 src/mlpack/core/tree/binary_space_tree/mean_split_impl.hpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mlpack/core/tree/binary_space_tree/mean_split_impl.hpp b/src/mlpack/core/tree/binary_space_tree/mean_split_impl.hpp
index 73edf6f..1fe630b 100644
--- a/src/mlpack/core/tree/binary_space_tree/mean_split_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/mean_split_impl.hpp
@@ -27,7 +27,7 @@ bool MeanSplit<BoundType, MatType>::SplitNode(const BoundType& bound,
   size_t ties = 0;
   for (size_t d = 0; d < data.n_rows; d++)
   {
-    double width = bound[d].Width();
+    const double width = bound[d].Width();
 
     if (width > maxWidth)
     {
@@ -64,8 +64,11 @@ bool MeanSplit<BoundType, MatType>::SplitNode(const BoundType& bound,
   if (maxWidth == 0) // All these points are the same.  We can't split.
     return false;
 
-  // Split in the middle of that dimension.
-  double splitVal = bound[splitDimension].Mid();
+  // Split in the mean of that dimension.
+  double splitVal = 0.0;
+  for (size_t i = begin; i < begin + count; ++i)
+    splitVal += data(splitDimension, i);
+  splitVal /= count;
 
   // Perform the actual splitting.  This will order the dataset such that points
   // with value in dimension splitDimension less than or equal to splitVal are



More information about the mlpack-git mailing list