[mlpack-git] master: Replace epsilon by percentage in kfn. (74648fa)
gitdub at mlpack.org
gitdub at mlpack.org
Wed Jun 22 14:09:07 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/a9f5622c8a14409111f2d71bf5c0f8aaa8ad4ae1...37fda23945b4f998cd5fa6ec011ae345236c8552
>---------------------------------------------------------------
commit 74648fa7f17cbe70f4215f5c6c93efbc1d3553a1
Author: MarcosPividori <marcos.pividori at gmail.com>
Date: Mon Jun 13 15:19:51 2016 -0300
Replace epsilon by percentage in kfn.
>---------------------------------------------------------------
74648fa7f17cbe70f4215f5c6c93efbc1d3553a1
src/mlpack/methods/neighbor_search/kfn_main.cpp | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/mlpack/methods/neighbor_search/kfn_main.cpp b/src/mlpack/methods/neighbor_search/kfn_main.cpp
index a2fbf2e..3a4e4b7 100644
--- a/src/mlpack/methods/neighbor_search/kfn_main.cpp
+++ b/src/mlpack/methods/neighbor_search/kfn_main.cpp
@@ -72,8 +72,10 @@ PARAM_INT("seed", "Random seed (if 0, std::time(NULL) is used).", "s", 0);
PARAM_FLAG("naive", "If true, O(n^2) naive mode is used for computation.", "N");
PARAM_FLAG("single_mode", "If true, single-tree search is used (as opposed to "
"dual-tree search).", "s");
-PARAM_DOUBLE("epsilon", "If specified, will do approximate furthest neighbor "
- "search with given relative error.", "e", 0);
+PARAM_DOUBLE("percentage", "If specified, will do approximate furthest neighbor"
+ " search. Must be in the range (0,1] (decimal form). Resultant neighbors "
+ "will be at least (p*100) % of the distance as the true furthest neighbor.",
+ "p", 1);
// Convenience typedef.
typedef NSModel<FurthestNeighborSort> KFNModel;
@@ -140,11 +142,11 @@ int main(int argc, char *argv[])
Log::Fatal << "Invalid leaf size: " << lsInt << ". Must be greater than 0."
<< endl;
- // Sanity check on epsilon.
- const double epsilon = CLI::GetParam<double>("epsilon");
- if (epsilon < 0)
- Log::Fatal << "Invalid epsilon: " << epsilon << ". Must be non-negative. "
- << endl;
+ // Sanity check on percentage.
+ const double percentage = CLI::GetParam<double>("percentage");
+ if (percentage <= 0 || percentage > 1)
+ Log::Fatal << "Invalid percentage: " << percentage
+ << ". Must be in the range (0,1] (decimal form)."<< endl;
// We either have to load the reference data, or we have to load the model.
NSModel<FurthestNeighborSort> kfn;
@@ -184,7 +186,7 @@ int main(int argc, char *argv[])
<< referenceSet.n_rows << "x" << referenceSet.n_cols << ")." << endl;
kfn.BuildModel(std::move(referenceSet), size_t(lsInt), naive, singleMode,
- epsilon);
+ 1 - percentage);
}
else
{
@@ -200,7 +202,7 @@ int main(int argc, char *argv[])
kfn.SingleMode() = CLI::HasParam("single_mode");
kfn.Naive() = CLI::HasParam("naive");
kfn.LeafSize() = size_t(lsInt);
- kfn.Epsilon() = epsilon;
+ kfn.Epsilon() = 1 - percentage;
}
// Perform search, if desired.
More information about the mlpack-git
mailing list