[mlpack-svn] r16808 - mlpack/trunk/src/mlpack/methods/neighbor_search
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Jul 10 10:04:45 EDT 2014
Author: rcurtin
Date: Thu Jul 10 10:04:45 2014
New Revision: 16808
Log:
Fix elusive bug that only occurred in particularly rare situations.
Modified:
mlpack/trunk/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
Modified: mlpack/trunk/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp Thu Jul 10 10:04:45 2014
@@ -151,7 +151,9 @@
const double score = traversalInfo.LastScore();
double adjustedScore;
- // In some cases we can just use the last base case.
+ // We want to set adjustedScore to be the distance between the centroid of the
+ // last query node and last reference node. We will do this by adjusting the
+ // last score. In some cases, we can just use the last base case.
if (tree::TreeTraits<TreeType>::FirstPointIsCentroid)
{
adjustedScore = traversalInfo.LastBaseCase();
@@ -162,10 +164,16 @@
}
else
{
+ // The last score is equal to the distance between the centroids minus the
+ // radii of the query and reference bounds along the axis of the line
+ // between the two centroids. In the best case, these radii are the
+ // furthest descendant distances, but that is not always true. It would
+ // take too long to calculate the exact radii, so we are forced to use
+ // MinimumBoundDistance() as a lower-bound approximation.
const double lastQueryDescDist =
- traversalInfo.LastQueryNode()->FurthestDescendantDistance();
+ traversalInfo.LastQueryNode()->MinimumBoundDistance();
const double lastRefDescDist =
- traversalInfo.LastReferenceNode()->FurthestDescendantDistance();
+ traversalInfo.LastReferenceNode()->MinimumBoundDistance();
adjustedScore = SortPolicy::CombineWorst(score, lastQueryDescDist);
adjustedScore = SortPolicy::CombineWorst(score, lastRefDescDist);
}
More information about the mlpack-svn
mailing list