[mlpack-svn] r16272 - in mlpack/trunk/src/mlpack: core/metrics core/tree/binary_space_tree core/tree/cover_tree tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Feb 10 12:45:51 EST 2014


Author: birm
Date: Mon Feb 10 12:45:51 2014
New Revision: 16272

Log:
Updated Test and some info for ToString.


Modified:
   mlpack/trunk/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
   mlpack/trunk/src/mlpack/tests/to_string_test.cpp

Modified: mlpack/trunk/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp	Mon Feb 10 12:45:51 2014
@@ -47,7 +47,22 @@
 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();
 }
 

Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp	Mon Feb 10 12:45:51 2014
@@ -719,13 +719,13 @@
   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);

Modified: mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp	Mon Feb 10 12:45:51 2014
@@ -994,9 +994,10 @@
   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());
     }

Modified: mlpack/trunk/src/mlpack/tests/to_string_test.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/tests/to_string_test.cpp	(original)
+++ mlpack/trunk/src/mlpack/tests/to_string_test.cpp	Mon Feb 10 12:45:51 2014
@@ -258,6 +258,26 @@
   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-svn mailing list