[mlpack-git] master, mlpack-1.0.x: Updated Test and some info for ToString. (2a96324)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:43:31 EST 2015
Repository : https://github.com/mlpack/mlpack
On branches: master,mlpack-1.0.x
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit 2a96324ffd3fb514184a32a6e8c1c95e8b13fcc4
Author: birm <birm at gatech.edu>
Date: Mon Feb 10 17:45:51 2014 +0000
Updated Test and some info for ToString.
>---------------------------------------------------------------
2a96324ffd3fb514184a32a6e8c1c95e8b13fcc4
.../core/metrics/mahalanobis_distance_impl.hpp | 15 +++++++++++++++
.../binary_space_tree/binary_space_tree_impl.hpp | 6 +++---
src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp | 5 +++--
src/mlpack/tests/to_string_test.cpp | 20 ++++++++++++++++++++
4 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp b/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp
index 9ca3510..954fa73 100644
--- a/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp
+++ b/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp
@@ -47,7 +47,22 @@ template<bool TakeRoot>
std::string MahalanobisDistance<TakeRoot>::ToString() const
{
std::ostringstream convert;
+ std::ostringstream convertb;
convert << "MahalanobisDistance [" << this << "]" << std::endl;
+ if (TakeRoot)
+ convert << " TakeRoot: TRUE" << std::endl;
+ if (covariance.size() < 65)
+ {
+ convert << " Covariance: " << std::endl;
+ convertb << covariance << std::endl;
+ convert << mlpack::util::Indent(convertb.str(),2);
+ }
+ else
+ {
+ convert << " Covariance matrix: " << covariance.n_rows << "x" ;
+ convert << covariance.n_cols << std::endl << " Range: [" ;
+ convert << covariance.min() << "," << covariance.max() << "]" << std::endl;
+ }
return convert.str();
}
diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
index 9150afa..26f2336 100644
--- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
@@ -719,13 +719,13 @@ std::string BinarySpaceTree<BoundType, StatisticType, MatType>::ToString() const
convert << " Leaf size: " << leafSize << std::endl;
convert << " Split dimension: " << splitDimension << std::endl;
- // How many levels should we print? This will print every level of the tree.
- if (left != NULL)
+ // How many levels should we print? This will print the top two tree levels.
+ if (left != NULL && parent == NULL)
{
convert << " Left child:" << std::endl;
convert << mlpack::util::Indent(left->ToString(), 2);
}
- if (right != NULL)
+ if (right != NULL && parent == NULL)
{
convert << " Right child:" << std::endl;
convert << mlpack::util::Indent(right->ToString(), 2);
diff --git a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
index 9d6a12b..ade0eb4 100644
--- a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
+++ b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
@@ -994,9 +994,10 @@ std::string CoverTree<MetricType, RootPointPolicy, StatisticType>::ToString()
convert << std::endl;
convert << "children:";
- if (IsLeaf() == false)
+ // How many levels should we print? This will print the top two tree levels.
+ if (IsLeaf() == false && parent == NULL)
{
- for (int i = 0; i < children.size(); i++)
+ for (size_t i = 0; i < children.size(); i++)
{
convert << std::endl << mlpack::util::Indent(children.at(i)->ToString());
}
diff --git a/src/mlpack/tests/to_string_test.cpp b/src/mlpack/tests/to_string_test.cpp
index c123f2a..475c3ba 100644
--- a/src/mlpack/tests/to_string_test.cpp
+++ b/src/mlpack/tests/to_string_test.cpp
@@ -258,6 +258,26 @@ BOOST_AUTO_TEST_CASE(BinSpaceString)
BOOST_REQUIRE_NE(s, "");
}
+BOOST_AUTO_TEST_CASE(CoverTreeString)
+{
+ arma::mat q(2, 50);
+ q.randu();
+ mlpack::tree::CoverTree<> d(q);
+ Log::Debug << d;
+ std::string s = d.ToString();
+ BOOST_REQUIRE_NE(s, "");
+}
+
+BOOST_AUTO_TEST_CASE(MRKDString)
+{
+ arma::mat q(2, 50);
+ q.randu();
+ mlpack::tree::MRKDStatistic d(q);
+ Log::Debug << d;
+ std::string s = d.ToString();
+ BOOST_REQUIRE_NE(s, "");
+}
+
BOOST_AUTO_TEST_CASE(CFString)
{
size_t a = 1 ;
More information about the mlpack-git
mailing list