[mlpack-svn] r15423 - mlpack/trunk/src/mlpack/methods/rann
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Jul 5 16:07:33 EDT 2013
Author: pram
Date: Fri Jul 5 16:07:32 2013
New Revision: 15423
Log:
Ticket #293 initial fix -- review waiting.
Modified:
mlpack/trunk/src/mlpack/methods/rann/ra_search_impl.hpp
mlpack/trunk/src/mlpack/methods/rann/ra_search_rules_impl.hpp
Modified: mlpack/trunk/src/mlpack/methods/rann/ra_search_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/rann/ra_search_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/methods/rann/ra_search_impl.hpp Fri Jul 5 16:07:32 2013
@@ -153,6 +153,21 @@
const bool firstLeafExact,
const size_t singleSampleLimit)
{
+ // Sanity check to make sure that the rank-approximation is
+ // greater than the number of neighbors requested.
+
+ // The rank approximation
+ size_t t = (size_t) std::ceil(tau * (double) referenceSet.n_cols
+ / 100.0);
+ if (t <= k)
+ {
+ Log::Warn << tau << "-rank-approximation => " << k <<
+ " neighbors requested from the top " << t <<
+ "." << std::endl;
+ Log::Fatal << "No approximation here, " <<
+ "hence quitting...please increase 'tau' and try again." << std::endl;
+ }
+
Timer::Start("computing_neighbors");
// If we have built the trees ourselves, then we will have to map all the
Modified: mlpack/trunk/src/mlpack/methods/rann/ra_search_rules_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/rann/ra_search_rules_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/methods/rann/ra_search_rules_impl.hpp Fri Jul 5 16:07:32 2013
@@ -97,6 +97,18 @@
// The rank approximation
size_t t = (size_t) std::ceil(tau * (double) n / 100.0);
+ // Sanity check here (if the previous one is somehow missed)
+ // to make sure that the rank-approximation is actually
+ // giving some approximation.
+ if (t <= k)
+ {
+ Log::Warn << tau << "-rank-approximation => " << k <<
+ " neighbors requested from the top " << t <<
+ "." << std::endl;
+ Log::Fatal << "No approximation here, " <<
+ "hence quitting...please increase 'tau' and try again." << std::endl;
+ }
+
double prob;
Log::Assert(alpha <= 1.0);
@@ -143,7 +155,7 @@
} while (!done);
- return (m + 1);
+ return (std::min(m + 1, n));
}
@@ -169,7 +181,7 @@
if (m < k)
return 0.0;
- if (m > n - t + k)
+ if (m > n - t + k - 1)
return 1.0;
double eps = (double) t / (double) n;
More information about the mlpack-svn
mailing list