[mlpack-git] master: Remove unnecessary code. (4a66098)

gitdub at mlpack.org gitdub at mlpack.org
Thu Aug 4 12:06:14 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/0f4b25acd6aaa14294c044874ba6cc0751712baa...0a19d07bd39e6223991976474bc79671ba8aa0f0

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

commit 4a660987553d3604d3e4ded1376156b77a1eac65
Author: MarcosPividori <marcos.pividori at gmail.com>
Date:   Thu Aug 4 13:06:14 2016 -0300

    Remove unnecessary code.


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

4a660987553d3604d3e4ded1376156b77a1eac65
 .../core/tree/binary_space_tree/mean_split.hpp     | 17 ------
 .../tree/binary_space_tree/mean_split_impl.hpp     | 71 ----------------------
 .../core/tree/binary_space_tree/midpoint_split.hpp | 17 ------
 .../tree/binary_space_tree/midpoint_split_impl.hpp | 65 --------------------
 4 files changed, 170 deletions(-)

diff --git a/src/mlpack/core/tree/binary_space_tree/mean_split.hpp b/src/mlpack/core/tree/binary_space_tree/mean_split.hpp
index 3ee8304..8450f9d 100644
--- a/src/mlpack/core/tree/binary_space_tree/mean_split.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/mean_split.hpp
@@ -65,23 +65,6 @@ class MeanSplit
                         const size_t count,
                         size_t& splitCol,
                         std::vector<size_t>& oldFromNew);
-
-  /**
-   * Determines the mean value in the dimension with maximum width.
-   *
-   * @param bound The bound used for this node.
-   * @param data The dataset used by the tree.
-   * @param points Vector of indexes of points to be considered.
-   * @param splitDimension This will be filled with the dimension the node is to
-   *    be split on.
-   * @param splitVal This will be filled with the mean value of splitDimension.
-   * @return Flag to determine if split is possible.
-   */
-  static bool SplitNode(const BoundType& bound,
-                        const MatType& data,
-                        const std::vector<size_t>& points,
-                        size_t& splitDimension,
-                        double& splitVal);
  private:
   /**
    * Reorder the dataset into two parts such that they lie on either side of
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 c73b608..f7fb6bc 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
@@ -171,77 +171,6 @@ bool MeanSplit<BoundType, MatType>::SplitNode(const BoundType& bound,
 }
 
 template<typename BoundType, typename MatType>
-bool MeanSplit<BoundType, MatType>::SplitNode(const BoundType& bound,
-                                              const MatType& data,
-                                              const std::vector<size_t>& points,
-                                              size_t& splitDimension,
-                                              double& splitVal)
-{
-  splitDimension = data.n_rows; // Indicate invalid.
-  double maxWidth = -1;
-
-  // Find the split dimension.  If the bound is tight, we only need to consult
-  // the bound's width.
-  if (bound::BoundTraits<BoundType>::HasTightBounds)
-  {
-    for (size_t d = 0; d < data.n_rows; d++)
-    {
-      const double width = bound[d].Width();
-
-      if (width > maxWidth)
-      {
-        maxWidth = width;
-        splitDimension = d;
-      }
-    }
-  }
-  else
-  {
-    // We must individually calculate bounding boxes.
-    math::Range* ranges = new math::Range[data.n_rows];
-    for (size_t i = 0; i < points.size(); ++i)
-    {
-      // Expand each dimension as necessary.
-      for (size_t d = 0; d < data.n_rows; ++d)
-      {
-        const double val = data(d, points[i]);
-        if (val < ranges[d].Lo())
-          ranges[d].Lo() = val;
-        if (val > ranges[d].Hi())
-          ranges[d].Hi() = val;
-      }
-    }
-
-    // Now, which is the widest?
-    for (size_t d = 0; d < data.n_rows; d++)
-    {
-      const double width = ranges[d].Width();
-      if (width > maxWidth)
-      {
-        maxWidth = width;
-        splitDimension = d;
-      }
-    }
-
-    delete[] ranges;
-  }
-
-  if (maxWidth == 0) // All these points are the same.  We can't split.
-    return false;
-
-  // Split in the mean of that dimension.
-  splitVal = 0.0;
-  for (size_t i = 0; i < points.size(); ++i)
-    splitVal += data(splitDimension, points[i]);
-  splitVal /= points.size();
-
-  Log::Assert(splitVal >= bound[splitDimension].Lo());
-  Log::Assert(splitVal <= bound[splitDimension].Hi());
-
-  return true;
-}
-
-template<typename BoundType, typename MatType>
 size_t MeanSplit<BoundType, MatType>::
     PerformSplit(MatType& data,
                  const size_t begin,
diff --git a/src/mlpack/core/tree/binary_space_tree/midpoint_split.hpp b/src/mlpack/core/tree/binary_space_tree/midpoint_split.hpp
index eaccc4a..f779002 100644
--- a/src/mlpack/core/tree/binary_space_tree/midpoint_split.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/midpoint_split.hpp
@@ -67,23 +67,6 @@ class MidpointSplit
                         size_t& splitCol,
                         std::vector<size_t>& oldFromNew);
 
-  /**
-   * Determines the midpoint value in the dimension with maximum width.
-   *
-   * @param bound The bound used for this node.
-   * @param data The dataset used by the tree.
-   * @param points Vector of indexes of points to be considered.
-   * @param splitDimension This will be filled with the dimension the node is to
-   *    be split on.
-   * @param splitVal This will be filled with the mid point value of
-   *    splitDimension.
-   * @return Flag to determine if split is possible.
-   */
-  static bool SplitNode(const BoundType& bound,
-                        const MatType& data,
-                        const std::vector<size_t>& points,
-                        size_t& splitDimension,
-                        double& splitVal);
  private:
   /**
    * Reorder the dataset into two parts such that they lie on either side of
diff --git a/src/mlpack/core/tree/binary_space_tree/midpoint_split_impl.hpp b/src/mlpack/core/tree/binary_space_tree/midpoint_split_impl.hpp
index 7b0085f..28dc707 100644
--- a/src/mlpack/core/tree/binary_space_tree/midpoint_split_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/midpoint_split_impl.hpp
@@ -169,71 +169,6 @@ bool MidpointSplit<BoundType, MatType>::SplitNode(const BoundType& bound,
 }
 
 template<typename BoundType, typename MatType>
-bool MidpointSplit<BoundType, MatType>::SplitNode(const BoundType& bound,
-                                                  const MatType& data,
-                                                  const std::vector<size_t>& points,
-                                                  size_t& splitDimension,
-                                                  double& splitVal)
-{
-  splitDimension = data.n_rows; // Indicate invalid.
-  double maxWidth = -1;
-
-  // Find the split dimension.  If the bound is tight, we only need to consult
-  // the bound's width.
-  if (bound::BoundTraits<BoundType>::HasTightBounds)
-  {
-    for (size_t d = 0; d < data.n_rows; d++)
-    {
-      const double width = bound[d].Width();
-
-      if (width > maxWidth)
-      {
-        maxWidth = width;
-        splitDimension = d;
-      }
-    }
-  }
-  else
-  {
-    // We must individually calculate bounding boxes.
-    math::Range* ranges = new math::Range[data.n_rows];
-    for (size_t i = 0; i < points.size(); ++i)
-    {
-      // Expand each dimension as necessary.
-      for (size_t d = 0; d < data.n_rows; ++d)
-      {
-        const double val = data(d, points[i]);
-        if (val < ranges[d].Lo())
-          ranges[d].Lo() = val;
-        if (val > ranges[d].Hi())
-          ranges[d].Hi() = val;
-      }
-    }
-
-    // Now, which is the widest?
-    for (size_t d = 0; d < data.n_rows; d++)
-    {
-      const double width = ranges[d].Width();
-      if (width > maxWidth)
-      {
-        maxWidth = width;
-        splitDimension = d;
-      }
-    }
-
-    delete[] ranges;
-  }
-
-  if (maxWidth <= 0) // All these points are the same.  We can't split.
-    return false;
-
-  // Split in the midpoint of that dimension.
-  splitVal = bound[splitDimension].Mid();
-
-  return true;
-}
-
-template<typename BoundType, typename MatType>
 size_t MidpointSplit<BoundType, MatType>::PerformSplit(
     MatType& data,
     const size_t begin,




More information about the mlpack-git mailing list