[mlpack-svn] r16870 - in mlpack/tags/mlpack-1.0.9/src/mlpack: core/tree core/tree/rectangle_tree methods/neighbor_search tests

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Sat Jul 26 11:23:23 EDT 2014


Author: rcurtin
Date: Sat Jul 26 11:23:22 2014
New Revision: 16870

Log:
Pull rectangle tree because it isn't done yet.


Removed:
   mlpack/tags/mlpack-1.0.9/src/mlpack/core/tree/rectangle_tree/
   mlpack/tags/mlpack-1.0.9/src/mlpack/tests/rectangle_tree_test.cpp
Modified:
   mlpack/tags/mlpack-1.0.9/src/mlpack/core/tree/CMakeLists.txt
   mlpack/tags/mlpack-1.0.9/src/mlpack/methods/neighbor_search/allknn_main.cpp
   mlpack/tags/mlpack-1.0.9/src/mlpack/methods/neighbor_search/neighbor_search.hpp
   mlpack/tags/mlpack-1.0.9/src/mlpack/tests/CMakeLists.txt
   mlpack/tags/mlpack-1.0.9/src/mlpack/tests/tree_test.cpp
   mlpack/tags/mlpack-1.0.9/src/mlpack/tests/tree_traits_test.cpp

Modified: mlpack/tags/mlpack-1.0.9/src/mlpack/core/tree/CMakeLists.txt
==============================================================================
--- mlpack/tags/mlpack-1.0.9/src/mlpack/core/tree/CMakeLists.txt	(original)
+++ mlpack/tags/mlpack-1.0.9/src/mlpack/core/tree/CMakeLists.txt	Sat Jul 26 11:23:22 2014
@@ -29,19 +29,6 @@
   mrkd_statistic.hpp
   mrkd_statistic_impl.hpp
   mrkd_statistic.cpp
-  rectangle_tree.hpp
-  rectangle_tree/rectangle_tree.hpp
-  rectangle_tree/rectangle_tree_impl.hpp
-  rectangle_tree/single_tree_traverser.hpp
-  rectangle_tree/single_tree_traverser_impl.hpp
-  rectangle_tree/dual_tree_traverser.hpp
-  rectangle_tree/dual_tree_traverser_impl.hpp
-  rectangle_tree/r_tree_split.hpp
-  rectangle_tree/r_tree_split_impl.hpp
-  rectangle_tree/r_tree_descent_heuristic.hpp
-  rectangle_tree/r_tree_descent_heuristic_impl.hpp
-  rectangle_tree/r_star_tree_descent_heuristic.hpp
-  rectangle_tree/r_star_tree_descent_heuristic_impl.hpp
   statistic.hpp
   traversal_info.hpp
   tree_traits.hpp

Modified: mlpack/tags/mlpack-1.0.9/src/mlpack/methods/neighbor_search/allknn_main.cpp
==============================================================================
--- mlpack/tags/mlpack-1.0.9/src/mlpack/methods/neighbor_search/allknn_main.cpp	(original)
+++ mlpack/tags/mlpack-1.0.9/src/mlpack/methods/neighbor_search/allknn_main.cpp	Sat Jul 26 11:23:22 2014
@@ -57,8 +57,6 @@
     "dual-tree search).", "S");
 PARAM_FLAG("cover_tree", "If true, use cover trees to perform the search "
     "(experimental, may be slow).", "c");
-PARAM_FLAG("r_tree", "If true, use an R-Tree to perform the search "
-    "(experimental, may be slow.  Currently automatically sets single_mode.).", "T");
 PARAM_FLAG("random_basis", "Before tree-building, project the data onto a "
     "random orthogonal basis.", "R");
 PARAM_INT("seed", "Random seed (if 0, std::time(NULL) is used).", "s", 0);
@@ -125,16 +123,6 @@
     Log::Warn << "--single_mode ignored because --naive is present." << endl;
   }
  
-   // cover_tree overrides r_tree.
-  if (CLI::HasParam("cover_tree") && CLI::HasParam("r_tree"))
-  {
-    Log::Warn << "--cover_tree overrides --r_tree." << endl;
-  } else if (!singleMode && CLI::HasParam("r_tree"))  // R_tree requires single mode.
-  {
-    Log::Warn << "--single_mode assumed because --r_tree is present." << endl;
-    singleMode = true;
-  }
-  
   if (naive)
     leafSize = referenceData.n_cols;
 
@@ -180,156 +168,90 @@
 
   if (!CLI::HasParam("cover_tree"))
   {
-    if(!CLI::HasParam("r_tree"))
-    {
-      // Because we may construct it differently, we need a pointer.
-      AllkNN* allknn = NULL;
+    // Because we may construct it differently, we need a pointer.
+    AllkNN* allknn = NULL;
 
-      // Mappings for when we build the tree.
-      std::vector<size_t> oldFromNewRefs;
+    // Mappings for when we build the tree.
+    std::vector<size_t> oldFromNewRefs;
 
-      // Build trees by hand, so we can save memory: if we pass a tree to
-      // NeighborSearch, it does not copy the matrix.
-      Log::Info << "Building reference tree..." << endl;
-      Timer::Start("tree_building");
-
-      BinarySpaceTree<bound::HRectBound<2>,
-	  NeighborSearchStat<NearestNeighborSort> >
-	  refTree(referenceData, oldFromNewRefs, leafSize);
-      BinarySpaceTree<bound::HRectBound<2>,
-	  NeighborSearchStat<NearestNeighborSort> >*
-	  queryTree = NULL; // Empty for now.
-
-      Timer::Stop("tree_building");
-
-      std::vector<size_t> oldFromNewQueries;
-
-      if (CLI::GetParam<string>("query_file") != "")
-      {
-	if (naive && leafSize < queryData.n_cols)
-	  leafSize = queryData.n_cols;
+    // Build trees by hand, so we can save memory: if we pass a tree to
+    // NeighborSearch, it does not copy the matrix.
+    Log::Info << "Building reference tree..." << endl;
+    Timer::Start("tree_building");
 
-	Log::Info << "Loaded query data from '" << queryFile << "' ("
-	    << queryData.n_rows << " x " << queryData.n_cols << ")." << endl;
+    BinarySpaceTree<bound::HRectBound<2>,
+        NeighborSearchStat<NearestNeighborSort> >
+        refTree(referenceData, oldFromNewRefs, leafSize);
+    BinarySpaceTree<bound::HRectBound<2>,
+        NeighborSearchStat<NearestNeighborSort> >*
+        queryTree = NULL; // Empty for now.
 
-	Log::Info << "Building query tree..." << endl;
+    Timer::Stop("tree_building");
 
-	// Build trees by hand, so we can save memory: if we pass a tree to
-	// NeighborSearch, it does not copy the matrix.
-	if (!singleMode)
-	{
-	  Timer::Start("tree_building");
+    std::vector<size_t> oldFromNewQueries;
 
-	  queryTree = new BinarySpaceTree<bound::HRectBound<2>,
-	      NeighborSearchStat<NearestNeighborSort> >(queryData,
-	      oldFromNewQueries, leafSize);
+    if (CLI::GetParam<string>("query_file") != "")
+    {
+      if (naive && leafSize < queryData.n_cols)
+        leafSize = queryData.n_cols;
 
-	  Timer::Stop("tree_building");
-	}
+      Log::Info << "Loaded query data from '" << queryFile << "' ("
+          << queryData.n_rows << " x " << queryData.n_cols << ")." << endl;
 
-	allknn = new AllkNN(&refTree, queryTree, referenceData, queryData,
-	    singleMode);
+      Log::Info << "Building query tree..." << endl;
 
-	Log::Info << "Tree built." << endl;
-      }
-      else
+      // Build trees by hand, so we can save memory: if we pass a tree to
+      // NeighborSearch, it does not copy the matrix.
+      if (!singleMode)
       {
-	allknn = new AllkNN(&refTree, referenceData, singleMode);
-
-	Log::Info << "Trees built." << endl;
-      }
-
-      arma::mat distancesOut;
-      arma::Mat<size_t> neighborsOut;
+        Timer::Start("tree_building");
 
-      Log::Info << "Computing " << k << " nearest neighbors..." << endl;
-      allknn->Search(k, neighborsOut, distancesOut);
+        queryTree = new BinarySpaceTree<bound::HRectBound<2>,
+            NeighborSearchStat<NearestNeighborSort> >(queryData,
+            oldFromNewQueries, leafSize);
 
-      Log::Info << "Neighbors computed." << endl;
+        Timer::Stop("tree_building");
+      }
 
-      // We have to map back to the original indices from before the tree
-      // construction.
-      Log::Info << "Re-mapping indices..." << endl;
-
-      // Map the results back to the correct places.
-      if ((CLI::GetParam<string>("query_file") != "") && !singleMode)
-	Unmap(neighborsOut, distancesOut, oldFromNewRefs, oldFromNewQueries,
-	    neighbors, distances);
-      else if ((CLI::GetParam<string>("query_file") != "") && singleMode)
-	Unmap(neighborsOut, distancesOut, oldFromNewRefs, neighbors, distances);
-      else
-	Unmap(neighborsOut, distancesOut, oldFromNewRefs, oldFromNewRefs,
-	    neighbors, distances);
-
-      // Clean up.
-      if (queryTree)
-	delete queryTree;
-
-      delete allknn;
-    } else { // R tree.
-      // Make sure to notify the user that they are using an r tree.
-      Log::Info << "Using r tree for nearest-neighbor calculation." << endl;
-      
-      // Because we may construct it differently, we need a pointer.
-      NeighborSearch<NearestNeighborSort, metric::LMetric<2, true>,
-      RectangleTree<tree::RStarTreeSplit<tree::RStarTreeDescentHeuristic, NeighborSearchStat<NearestNeighborSort>, arma::mat>,
-		    tree::RStarTreeDescentHeuristic,
-		    NeighborSearchStat<NearestNeighborSort>,
-		    arma::mat> >* allknn = NULL;
+      allknn = new AllkNN(&refTree, queryTree, referenceData, queryData,
+          singleMode);
 
-      // Build trees by hand, so we can save memory: if we pass a tree to
-      // NeighborSearch, it does not copy the matrix.
-      Log::Info << "Building reference tree..." << endl;
-      Timer::Start("tree_building");
+      Log::Info << "Tree built." << endl;
+    }
+    else
+    {
+      allknn = new AllkNN(&refTree, referenceData, singleMode);
 
-      RectangleTree<tree::RStarTreeSplit<tree::RStarTreeDescentHeuristic, NeighborSearchStat<NearestNeighborSort>, arma::mat>,
-		    tree::RStarTreeDescentHeuristic,
-		    NeighborSearchStat<NearestNeighborSort>,
-		    arma::mat>
-      refTree(referenceData, leafSize, leafSize/3, 5, 2, 0);
-
-      RectangleTree<tree::RStarTreeSplit<tree::RStarTreeDescentHeuristic, NeighborSearchStat<NearestNeighborSort>, arma::mat>,
-		    tree::RStarTreeDescentHeuristic,
-		    NeighborSearchStat<NearestNeighborSort>,
-		    arma::mat>*
-      queryTree = NULL; // Empty for now.
-
-      Timer::Stop("tree_building");
-      
-      if (CLI::GetParam<string>("query_file") != "")
-      {
-	Log::Info << "Loaded query data from '" << queryFile << "' ("
-	    << queryData.n_rows << " x " << queryData.n_cols << ")." << endl;
+      Log::Info << "Trees built." << endl;
+    }
 
-        allknn = new NeighborSearch<NearestNeighborSort, metric::LMetric<2, true>,
-        RectangleTree<tree::RStarTreeSplit<tree::RStarTreeDescentHeuristic, NeighborSearchStat<NearestNeighborSort>, arma::mat>,
-	  	      tree::RStarTreeDescentHeuristic,
-  		      NeighborSearchStat<NearestNeighborSort>,
-  		      arma::mat> >(&refTree, queryTree,
-          referenceData, queryData, singleMode);
-      } else
-      {
-	      allknn = new NeighborSearch<NearestNeighborSort, metric::LMetric<2, true>,
-      RectangleTree<tree::RStarTreeSplit<tree::RStarTreeDescentHeuristic, NeighborSearchStat<NearestNeighborSort>, arma::mat>,
-		    tree::RStarTreeDescentHeuristic,
-		    NeighborSearchStat<NearestNeighborSort>,
-		    arma::mat> >(&refTree,
-        referenceData, singleMode);
-      }
-      Log::Info << "Tree built." << endl;
-      
-      //arma::mat distancesOut;
-      //arma::Mat<size_t> neighborsOut;
+    arma::mat distancesOut;
+    arma::Mat<size_t> neighborsOut;
 
-      Log::Info << "Computing " << k << " nearest neighbors..." << endl;
-      allknn->Search(k, neighbors, distances);
+    Log::Info << "Computing " << k << " nearest neighbors..." << endl;
+    allknn->Search(k, neighborsOut, distancesOut);
 
-      Log::Info << "Neighbors computed." << endl;
+    Log::Info << "Neighbors computed." << endl;
 
+    // We have to map back to the original indices from before the tree
+    // construction.
+    Log::Info << "Re-mapping indices..." << endl;
+
+    // Map the results back to the correct places.
+    if ((CLI::GetParam<string>("query_file") != "") && !singleMode)
+      Unmap(neighborsOut, distancesOut, oldFromNewRefs, oldFromNewQueries,
+          neighbors, distances);
+    else if ((CLI::GetParam<string>("query_file") != "") && singleMode)
+      Unmap(neighborsOut, distancesOut, oldFromNewRefs, neighbors, distances);
+    else
+      Unmap(neighborsOut, distancesOut, oldFromNewRefs, oldFromNewRefs,
+          neighbors, distances);
 
+    // Clean up.
+    if (queryTree)
+      delete queryTree;
 
-      delete allknn;
-    }
+    delete allknn;
   }
   else // Cover trees.
   {
@@ -388,7 +310,7 @@
       delete queryTree;
   }
 
-  // Save put.
+  // Save output.
   data::Save(distancesFile, distances);
   data::Save(neighborsFile, neighbors);
 }

Modified: mlpack/tags/mlpack-1.0.9/src/mlpack/methods/neighbor_search/neighbor_search.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.9/src/mlpack/methods/neighbor_search/neighbor_search.hpp	(original)
+++ mlpack/tags/mlpack-1.0.9/src/mlpack/methods/neighbor_search/neighbor_search.hpp	Sat Jul 26 11:23:22 2014
@@ -13,7 +13,6 @@
 #include <string>
 
 #include <mlpack/core/tree/binary_space_tree.hpp>
-#include <mlpack/core/tree/rectangle_tree.hpp>
 
 #include <mlpack/core/metrics/lmetric.hpp>
 #include "neighbor_search_stat.hpp"

Modified: mlpack/tags/mlpack-1.0.9/src/mlpack/tests/CMakeLists.txt
==============================================================================
--- mlpack/tags/mlpack-1.0.9/src/mlpack/tests/CMakeLists.txt	(original)
+++ mlpack/tags/mlpack-1.0.9/src/mlpack/tests/CMakeLists.txt	Sat Jul 26 11:23:22 2014
@@ -40,7 +40,6 @@
   quic_svd_test.cpp
   radical_test.cpp
   range_search_test.cpp
-  rectangle_tree_test.cpp
   regularized_svd_test.cpp
   sa_test.cpp
   save_restore_utility_test.cpp

Modified: mlpack/tags/mlpack-1.0.9/src/mlpack/tests/tree_test.cpp
==============================================================================
--- mlpack/tags/mlpack-1.0.9/src/mlpack/tests/tree_test.cpp	(original)
+++ mlpack/tags/mlpack-1.0.9/src/mlpack/tests/tree_test.cpp	Sat Jul 26 11:23:22 2014
@@ -8,7 +8,6 @@
 #include <mlpack/core/tree/binary_space_tree/binary_space_tree.hpp>
 #include <mlpack/core/metrics/lmetric.hpp>
 #include <mlpack/core/tree/cover_tree/cover_tree.hpp>
-#include <mlpack/core/tree/rectangle_tree.hpp>
 
 #include <queue>
 #include <stack>

Modified: mlpack/tags/mlpack-1.0.9/src/mlpack/tests/tree_traits_test.cpp
==============================================================================
--- mlpack/tags/mlpack-1.0.9/src/mlpack/tests/tree_traits_test.cpp	(original)
+++ mlpack/tags/mlpack-1.0.9/src/mlpack/tests/tree_traits_test.cpp	Sat Jul 26 11:23:22 2014
@@ -12,7 +12,6 @@
 #include <mlpack/core/tree/tree_traits.hpp>
 #include <mlpack/core/tree/binary_space_tree.hpp>
 #include <mlpack/core/tree/cover_tree.hpp>
-#include <mlpack/core/tree/rectangle_tree.hpp>
 
 #include <boost/test/unit_test.hpp>
 #include "old_boost_test_definitions.hpp"



More information about the mlpack-svn mailing list