[mlpack-git] master: Fixed an error with duplicated base cases. Fixed tests. (ce2ab20)
gitdub at mlpack.org
gitdub at mlpack.org
Sat Aug 6 13:45:11 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/acd81e11579f69e75aa8406b2982328c88cf1fde...1e9f0f39ea4443f0d595c395871ea8c6b27443af
>---------------------------------------------------------------
commit ce2ab2080677cf1b398b763014841639088f3a37
Author: Mikhail Lozhnikov <lozhnikovma at gmail.com>
Date: Sat Aug 6 20:45:11 2016 +0300
Fixed an error with duplicated base cases. Fixed tests.
>---------------------------------------------------------------
ce2ab2080677cf1b398b763014841639088f3a37
.../core/tree/vantage_point_tree/dual_tree_traverser_impl.hpp | 4 +---
src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp | 6 +++++-
src/mlpack/methods/range_search/range_search_rules_impl.hpp | 6 +++++-
src/mlpack/tests/vantage_point_tree_test.cpp | 2 +-
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/mlpack/core/tree/vantage_point_tree/dual_tree_traverser_impl.hpp b/src/mlpack/core/tree/vantage_point_tree/dual_tree_traverser_impl.hpp
index 3c1c503..4a9e39e 100644
--- a/src/mlpack/core/tree/vantage_point_tree/dual_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/vantage_point_tree/dual_tree_traverser_impl.hpp
@@ -79,9 +79,7 @@ DualTreeTraverser<RuleType>::Traverse(
numBaseCases += referenceNode.Count();
}
}
- else if (((!queryNode.IsLeaf()) && referenceNode.IsLeaf()) ||
- (queryNode.NumDescendants() > 3 * referenceNode.NumDescendants() &&
- !queryNode.IsLeaf() && !referenceNode.IsLeaf()))
+ else if ((!queryNode.IsLeaf()) && referenceNode.IsLeaf())
{
// We have to recurse down the query node. In this case the recursion order
// does not matter.
diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
index 0948322..88fbdf6 100644
--- a/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
+++ b/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
@@ -282,11 +282,15 @@ inline double NeighborSearchRules<SortPolicy, MetricType, TreeType>::Score(
traversalInfo.LastBaseCase() = baseCase;
}
else if (tree::TreeTraits<TreeType>::FirstSiblingFirstPointIsCentroid &&
- queryNode.Parent() && referenceNode.Parent())
+ queryNode.Parent() && referenceNode.Parent() &&
+ !queryNode.IsLeaf() && !referenceNode.IsLeaf())
{
// The first point of the first sibling is the centroid, so we have to
// calculate the distance between the centroids if we have not calculated
// that yet.
+ // We can not use this property if the traverser does not recurse down
+ // the query or the reference node since two siblings may be traversed
+ // in two different branches of the recursion.
double baseCase;
TreeType* firstQuerySibling = &queryNode.Parent()->Child(0);
diff --git a/src/mlpack/methods/range_search/range_search_rules_impl.hpp b/src/mlpack/methods/range_search/range_search_rules_impl.hpp
index b0b56a7..fddcad3 100644
--- a/src/mlpack/methods/range_search/range_search_rules_impl.hpp
+++ b/src/mlpack/methods/range_search/range_search_rules_impl.hpp
@@ -177,11 +177,15 @@ double RangeSearchRules<MetricType, TreeType>::Score(TreeType& queryNode,
traversalInfo.LastBaseCase() = baseCase;
}
else if (tree::TreeTraits<TreeType>::FirstSiblingFirstPointIsCentroid &&
- queryNode.Parent() && referenceNode.Parent())
+ queryNode.Parent() && referenceNode.Parent() &&
+ !queryNode.IsLeaf() && !referenceNode.IsLeaf())
{
// The first point of the first sibling is the centroid, so we have to
// calculate the distance between the centroids if we have not calculated
// that yet.
+ // We can not use this property if the traverser does not recurse down
+ // the query or the reference node since two siblings may be traversed
+ // in two different branches of the recursion.
double baseCase;
TreeType* firstQuerySibling = &queryNode.Parent()->Child(0);
diff --git a/src/mlpack/tests/vantage_point_tree_test.cpp b/src/mlpack/tests/vantage_point_tree_test.cpp
index 3097af2..696313a 100644
--- a/src/mlpack/tests/vantage_point_tree_test.cpp
+++ b/src/mlpack/tests/vantage_point_tree_test.cpp
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(VPTreeTraitsTest)
b = TreeTraits<TreeType>::RearrangesDataset;
BOOST_REQUIRE_EQUAL(b, true);
b = TreeTraits<TreeType>::BinaryTree;
- BOOST_REQUIRE_EQUAL(b, true);
+ BOOST_REQUIRE_EQUAL(b, false);
}
BOOST_AUTO_TEST_CASE(HollowBallBoundTest)
More information about the mlpack-git
mailing list