[mlpack-git] master: Added the Hilbert R tree to NSModel (a46b834)

gitdub at mlpack.org gitdub at mlpack.org
Tue Jun 28 10:38:02 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/9dd66c7312ffcce6bc7b51aff00d38b75263f4b0...6077f120935e10ffa01d80a8398e28a90a8d011a

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

commit a46b834654dc4f25b95675fa6215ec147ead2e7f
Author: Mikhail Lozhnikov <lozhnikovma at gmail.com>
Date:   Tue Jun 28 17:38:02 2016 +0300

    Added the Hilbert R tree to NSModel


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

a46b834654dc4f25b95675fa6215ec147ead2e7f
 src/mlpack/methods/neighbor_search/kfn_main.cpp      | 6 ++++--
 src/mlpack/methods/neighbor_search/knn_main.cpp      | 6 ++++--
 src/mlpack/methods/neighbor_search/ns_model.hpp      | 6 ++++--
 src/mlpack/methods/neighbor_search/ns_model_impl.hpp | 6 ++++++
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/mlpack/methods/neighbor_search/kfn_main.cpp b/src/mlpack/methods/neighbor_search/kfn_main.cpp
index 163e8ed..254dc52 100644
--- a/src/mlpack/methods/neighbor_search/kfn_main.cpp
+++ b/src/mlpack/methods/neighbor_search/kfn_main.cpp
@@ -62,7 +62,7 @@ PARAM_INT("k", "Number of furthest neighbors to find.", "k", 0);
 // The user may specify the type of tree to use, and a few pararmeters for tree
 // building.
 PARAM_STRING("tree_type", "Type of tree to use: 'kd', 'cover', 'r', 'r-star', "
-    "'x', 'ball'.", "t", "kd");
+    "'x', 'ball', 'hilbert-r'.", "t", "kd");
 PARAM_INT("leaf_size", "Leaf size for tree building.", "l", 20);
 PARAM_FLAG("random_basis", "Before tree-building, project the data onto a "
     "random orthogonal basis.", "R");
@@ -186,9 +186,11 @@ int main(int argc, char *argv[])
       tree = KFNModel::BALL_TREE;
     else if (treeType == "x")
       tree = KFNModel::X_TREE;
+    else if (treeType == "hilbert-r")
+      tree = KFNModel::HILBERT_R_TREE;
     else
       Log::Fatal << "Unknown tree type '" << treeType << "'; valid choices are "
-          << "'kd', 'cover', 'r', 'r-star', 'x' and 'ball'." << endl;
+          << "'kd', 'cover', 'r', 'r-star', 'x', 'ball' and 'hilbert-r'." << endl;
 
     kfn.TreeType() = tree;
     kfn.RandomBasis() = randomBasis;
diff --git a/src/mlpack/methods/neighbor_search/knn_main.cpp b/src/mlpack/methods/neighbor_search/knn_main.cpp
index 880f5db..aad1991 100644
--- a/src/mlpack/methods/neighbor_search/knn_main.cpp
+++ b/src/mlpack/methods/neighbor_search/knn_main.cpp
@@ -63,7 +63,7 @@ PARAM_INT("k", "Number of nearest neighbors to find.", "k", 0);
 // The user may specify the type of tree to use, and a few parameters for tree
 // building.
 PARAM_STRING("tree_type", "Type of tree to use: 'kd', 'cover', 'r', 'r-star', "
-    "'x', 'ball'.", "t", "kd");
+    "'x', 'ball', 'hilbert-r'.", "t", "kd");
 PARAM_INT("leaf_size", "Leaf size for tree building (used for kd-trees, R "
     "trees, and R* trees).", "l", 20);
 PARAM_FLAG("random_basis", "Before tree-building, project the data onto a "
@@ -172,9 +172,11 @@ int main(int argc, char *argv[])
       tree = KNNModel::BALL_TREE;
     else if (treeType == "x")
       tree = KNNModel::X_TREE;
+    else if (treeType == "hilbert-r")
+      tree = KNNModel::HILBERT_R_TREE;
     else
       Log::Fatal << "Unknown tree type '" << treeType << "'; valid choices are "
-          << "'kd', 'cover', 'r', 'r-star', 'x' and 'ball'." << endl;
+          << "'kd', 'cover', 'r', 'r-star', 'x', 'ball' and 'hilbert-r'." << endl;
 
     knn.TreeType() = tree;
     knn.RandomBasis() = randomBasis;
diff --git a/src/mlpack/methods/neighbor_search/ns_model.hpp b/src/mlpack/methods/neighbor_search/ns_model.hpp
index 711d640..55e9e91 100644
--- a/src/mlpack/methods/neighbor_search/ns_model.hpp
+++ b/src/mlpack/methods/neighbor_search/ns_model.hpp
@@ -229,7 +229,8 @@ class NSModel
     R_TREE,
     R_STAR_TREE,
     BALL_TREE,
-    X_TREE
+    X_TREE,
+    HILBERT_R_TREE
   };
 
  private:
@@ -253,7 +254,8 @@ class NSModel
                  NSType<SortPolicy, tree::RTree>*,
                  NSType<SortPolicy, tree::RStarTree>*,
                  NSType<SortPolicy, tree::BallTree>*,
-                 NSType<SortPolicy, tree::XTree>*> nSearch;
+                 NSType<SortPolicy, tree::XTree>*,
+                 NSType<SortPolicy, tree::HilbertRTree>*> nSearch;
 
  public:
   /**
diff --git a/src/mlpack/methods/neighbor_search/ns_model_impl.hpp b/src/mlpack/methods/neighbor_search/ns_model_impl.hpp
index da8ab07..ae34feb 100644
--- a/src/mlpack/methods/neighbor_search/ns_model_impl.hpp
+++ b/src/mlpack/methods/neighbor_search/ns_model_impl.hpp
@@ -382,6 +382,10 @@ void NSModel<SortPolicy>::BuildModel(arma::mat&& referenceSet,
     case X_TREE:
       nSearch = new NSType<SortPolicy, tree::XTree>(naive, singleMode, epsilon);
       break;
+    case HILBERT_R_TREE:
+      nSearch = new NSType<SortPolicy, tree::HilbertRTree>(naive, singleMode,
+          epsilon);
+      break;
   }
 
   TrainVisitor<SortPolicy> tn(std::move(referenceSet), leafSize);
@@ -460,6 +464,8 @@ std::string NSModel<SortPolicy>::TreeName() const
       return "ball tree";
     case X_TREE:
       return "X tree";
+    case HILBERT_R_TREE:
+      return "Hilbert R tree";
     default:
       return "unknown tree";
   }




More information about the mlpack-git mailing list