[mlpack-git] master: Remove MRKDStatistic; its functionality is gone. It's been replaced by some of the other KMeans code. (681ffc1)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:12:00 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 681ffc10d3a30599914b8291a409e0563137688a
Author: Ryan Curtin <ryan at ratml.org>
Date:   Mon Jan 12 11:44:40 2015 -0500

    Remove MRKDStatistic; its functionality is gone.
    It's been replaced by some of the other KMeans code.


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

681ffc10d3a30599914b8291a409e0563137688a
 src/mlpack/core/tree/CMakeLists.txt          |  3 -
 src/mlpack/core/tree/mrkd_statistic.cpp      | 43 ------------
 src/mlpack/core/tree/mrkd_statistic.hpp      | 98 ----------------------------
 src/mlpack/core/tree/mrkd_statistic_impl.hpp | 93 --------------------------
 src/mlpack/methods/kmeans/kmeans_impl.hpp    |  1 -
 src/mlpack/tests/to_string_test.cpp          | 12 ----
 6 files changed, 250 deletions(-)

diff --git a/src/mlpack/core/tree/CMakeLists.txt b/src/mlpack/core/tree/CMakeLists.txt
index f9b9028..5491dd8 100644
--- a/src/mlpack/core/tree/CMakeLists.txt
+++ b/src/mlpack/core/tree/CMakeLists.txt
@@ -28,9 +28,6 @@ set(SOURCES
   example_tree.hpp
   hrectbound.hpp
   hrectbound_impl.hpp
-  mrkd_statistic.hpp
-  mrkd_statistic_impl.hpp
-  mrkd_statistic.cpp
   rectangle_tree.hpp
   rectangle_tree/rectangle_tree.hpp
   rectangle_tree/rectangle_tree_impl.hpp
diff --git a/src/mlpack/core/tree/mrkd_statistic.cpp b/src/mlpack/core/tree/mrkd_statistic.cpp
deleted file mode 100644
index 17c55e5..0000000
--- a/src/mlpack/core/tree/mrkd_statistic.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * @file mrkd_statistic.cpp
- * @author James Cline
- *
- * Definition of the statistic for multi-resolution kd-trees.
- */
-#include "mrkd_statistic.hpp"
-
-using namespace mlpack;
-using namespace mlpack::tree;
-
-MRKDStatistic::MRKDStatistic() :
-    dataset(NULL),
-    begin(0),
-    count(0),
-    leftStat(NULL),
-    rightStat(NULL),
-    parentStat(NULL)
-{ }
-
-/**
- * Returns a string representation of this object.
- */
-std::string MRKDStatistic::ToString() const
-{
-  std::ostringstream convert;
-
-  convert << "MRKDStatistic [" << this << std::endl;
-  convert << "begin: " << begin << std::endl;
-  convert << "count: " << count << std::endl;
-  convert << "sumOfSquaredNorms: " << sumOfSquaredNorms << std::endl;
-  if (leftStat != NULL)
-  {
-    convert << "leftStat:" << std::endl;
-    convert << mlpack::util::Indent(leftStat->ToString());
-  }
-  if (rightStat != NULL)
-  {
-    convert << "rightStat:" << std::endl;
-    convert << mlpack::util::Indent(rightStat->ToString());
-  }
-  return convert.str();
-}
diff --git a/src/mlpack/core/tree/mrkd_statistic.hpp b/src/mlpack/core/tree/mrkd_statistic.hpp
deleted file mode 100644
index 24e4058..0000000
--- a/src/mlpack/core/tree/mrkd_statistic.hpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * @file mrkd_statistic.hpp
- * @author James Cline
- *
- * Definition of the statistic for multi-resolution kd-trees.
- */
-#ifndef __MLPACK_CORE_TREE_MRKD_STATISTIC_HPP
-#define __MLPACK_CORE_TREE_MRKD_STATISTIC_HPP
-
-#include <mlpack/core.hpp>
-
-namespace mlpack {
-namespace tree {
-
-/**
- * Statistic for multi-resolution kd-trees.
- */
-class MRKDStatistic
-{
- public:
-  //! Initialize an empty statistic.
-  MRKDStatistic();
-
-  /**
-   * This constructor is called when a node is finished initializing.
-   *
-   * @param node The node that has been finished.
-   */
-  template<typename TreeType>
-  MRKDStatistic(const TreeType& /* node */);
-
-  /**
-   * Returns a string representation of this object.
-   */
-  std::string ToString() const;
-
-  //! Get the index of the initial item in the dataset.
-  size_t Begin() const { return begin; }
-  //! Modify the index of the initial item in the dataset.
-  size_t& Begin() { return begin; }
-
-  //! Get the number of items in the dataset.
-  size_t Count() const { return count; }
-  //! Modify the number of items in the dataset.
-  size_t& Count() { return count; }
-
-  //! Get the center of mass.
-  const arma::colvec& CenterOfMass() const { return centerOfMass; }
-  //! Modify the center of mass.
-  arma::colvec& CenterOfMass() { return centerOfMass; }
-
-  //! Get the index of the dominating centroid.
-  size_t DominatingCentroid() const { return dominatingCentroid; }
-  //! Modify the index of the dominating centroid.
-  size_t& DominatingCentroid() { return dominatingCentroid; }
-
-  //! Access the whitelist.
-  const std::vector<size_t>& Whitelist() const { return whitelist; }
-  //! Modify the whitelist.
-  std::vector<size_t>& Whitelist() { return whitelist; }
-
- private:
-  //! The data points this object contains.
-  const arma::mat* dataset;
-  //! The initial item in the dataset, so we don't have to make a copy.
-  size_t begin;
-  //! The number of items in the dataset.
-  size_t count;
-  //! The left child.
-  const MRKDStatistic* leftStat;
-  //! The right child.
-  const MRKDStatistic* rightStat;
-  //! A link to the parent node; NULL if this is the root.
-  const MRKDStatistic* parentStat;
-
-  // Computed statistics.
-  //! The center of mass for this dataset.
-  arma::colvec centerOfMass;
-  //! The sum of the squared Euclidean norms for this dataset.
-  double sumOfSquaredNorms;
-
-  // There may be a better place to store this -- HRectBound?
-  //! The index of the dominating centroid of the associated hyperrectangle.
-  size_t dominatingCentroid;
-
-  //! The list of centroids that cannot own this hyperrectangle.
-  std::vector<size_t> whitelist;
-  //! Whether or not the whitelist is valid.
-  bool isWhitelistValid;
-};
-
-}; // namespace tree
-}; // namespace mlpack
-
-// Include implementation.
-#include "mrkd_statistic_impl.hpp"
-
-#endif // __MLPACK_CORE_TREE_MRKD_STATISTIC_HPP
diff --git a/src/mlpack/core/tree/mrkd_statistic_impl.hpp b/src/mlpack/core/tree/mrkd_statistic_impl.hpp
deleted file mode 100644
index 2a69223..0000000
--- a/src/mlpack/core/tree/mrkd_statistic_impl.hpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * @file mrkd_statistic_impl.hpp
- * @author James Cline
- *
- * Definition of the statistic for multi-resolution kd-trees.
- */
-#ifndef __MLPACK_CORE_TREE_MRKD_STATISTIC_IMPL_HPP
-#define __MLPACK_CORE_TREE_MRKD_STATISTIC_IMPL_HPP
-
-// In case it hasn't already been included.
-#include "mrkd_statistic.hpp"
-
-namespace mlpack {
-namespace tree {
-
-template<typename TreeType>
-MRKDStatistic::MRKDStatistic(const TreeType& /* node */) :
-    dataset(NULL),
-    begin(0),
-    count(0),
-    leftStat(NULL),
-    rightStat(NULL),
-    parentStat(NULL)
-{ }
-
-/**
- * This constructor is called when a leaf is created.
- *
- * @param dataset Matrix that the tree is being built on.
- * @param begin Starting index corresponding to this leaf.
- * @param count Number of points held in this leaf.
- *
-template<typename MatType>
-MRKDStatistic::MRKDStatistic(const TreeType& node) :
-    dataset(&dataset),
-    begin(begin),
-    count(count),
-    leftStat(NULL),
-    rightStat(NULL),
-    parentStat(NULL)
-{
-  centerOfMass = dataset.col(begin);
-  for (size_t i = begin + 1; i < begin + count; ++i)
-    centerOfMass += dataset.col(i);
-
-  sumOfSquaredNorms = 0.0;
-  for (size_t i = begin; i < begin + count; ++i)
-    sumOfSquaredNorms += arma::norm(dataset.col(i), 2);
-}
-
- **
- * This constructor is called when a non-leaf node is created.
- * This lets you build fast bottom-up statistics when building trees.
- *
- * @param dataset Matrix that the tree is being built on.
- * @param begin Starting index corresponding to this leaf.
- * @param count Number of points held in this leaf.
- * @param leftStat MRKDStatistic object of the left child node.
- * @param rightStat MRKDStatistic object of the right child node.
- *
-template<typename MatType>
-MRKDStatistic::MRKDStatistic(const MatType& dataset,
-                             const size_t begin,
-                             const size_t count,
-                             MRKDStatistic& leftStat,
-                             MRKDStatistic& rightStat) :
-    dataset(&dataset),
-    begin(begin),
-    count(count),
-    leftStat(&leftStat),
-    rightStat(&rightStat),
-    parentStat(NULL)
-{
-  sumOfSquaredNorms = leftStat.sumOfSquaredNorms + rightStat.sumOfSquaredNorms;
-
-  *
-  centerOfMass = ((leftStat.centerOfMass * leftStat.count) +
-                  (rightStat.centerOfMass * rightStat.count)) /
-                  (leftStat.count + rightStat.count);
-  *
-  centerOfMass = leftStat.centerOfMass + rightStat.centerOfMass;
-
-  isWhitelistValid = false;
-
-  leftStat.parentStat = this;
-  rightStat.parentStat = this;
-}
-*/
-
-}; // namespace tree
-}; // namespace mlpack
-
-#endif // __MLPACK_CORE_TREE_MRKD_STATISTIC_IMPL_HPP
diff --git a/src/mlpack/methods/kmeans/kmeans_impl.hpp b/src/mlpack/methods/kmeans/kmeans_impl.hpp
index 317d0c4..9bdf29c 100644
--- a/src/mlpack/methods/kmeans/kmeans_impl.hpp
+++ b/src/mlpack/methods/kmeans/kmeans_impl.hpp
@@ -7,7 +7,6 @@
  */
 #include "kmeans.hpp"
 
-#include <mlpack/core/tree/mrkd_statistic.hpp>
 #include <mlpack/core/metrics/lmetric.hpp>
 
 namespace mlpack {
diff --git a/src/mlpack/tests/to_string_test.cpp b/src/mlpack/tests/to_string_test.cpp
index bac9a27..bdb6f6e 100644
--- a/src/mlpack/tests/to_string_test.cpp
+++ b/src/mlpack/tests/to_string_test.cpp
@@ -29,7 +29,6 @@
 #include <mlpack/core/tree/ballbound.hpp>
 #include <mlpack/core/tree/binary_space_tree.hpp>
 #include <mlpack/core/tree/bounds.hpp>
-#include <mlpack/core/tree/mrkd_statistic.hpp>
 #include <mlpack/core/tree/hrectbound.hpp>
 #include <mlpack/core/tree/statistic.hpp>
 
@@ -294,17 +293,6 @@ BOOST_AUTO_TEST_CASE(CoverTreeString)
   BOOST_REQUIRE_NE(s, "");
 }
 
-BOOST_AUTO_TEST_CASE(MRKDString)
-{
-  arma::mat q(2, 50);
-  q.randu();
-  mlpack::tree::MRKDStatistic d(q);
-  Log::Debug << d;
-  testOstream << d;
-  std::string s = d.ToString();
-  BOOST_REQUIRE_NE(s, "");
-}
-
 BOOST_AUTO_TEST_CASE(CFString)
 {
   arma::mat c(3, 3);



More information about the mlpack-git mailing list