[mlpack-git] master: Properly update search model. (ecaf1bf)
gitdub at mlpack.org
gitdub at mlpack.org
Wed Aug 17 16:23:14 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/0f4b25acd6aaa14294c044874ba6cc0751712baa...0a19d07bd39e6223991976474bc79671ba8aa0f0
>---------------------------------------------------------------
commit ecaf1bf80976b83044cf9d90b65aa9a02e4efba1
Author: MarcosPividori <marcos.pividori at gmail.com>
Date: Wed Aug 17 17:23:14 2016 -0300
Properly update search model.
>---------------------------------------------------------------
ecaf1bf80976b83044cf9d90b65aa9a02e4efba1
src/mlpack/methods/neighbor_search/kfn_main.cpp | 27 ++++++++++---------
src/mlpack/methods/neighbor_search/knn_main.cpp | 36 ++++++++++++++-----------
2 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/src/mlpack/methods/neighbor_search/kfn_main.cpp b/src/mlpack/methods/neighbor_search/kfn_main.cpp
index f56b890..09e81df 100644
--- a/src/mlpack/methods/neighbor_search/kfn_main.cpp
+++ b/src/mlpack/methods/neighbor_search/kfn_main.cpp
@@ -115,15 +115,14 @@ int main(int argc, char *argv[])
if (CLI::HasParam("tree_type"))
Log::Warn << "--tree_type (-t) will be ignored because --input_model_file"
<< " is specified." << endl;
- if (CLI::HasParam("leaf_size"))
- Log::Warn << "--leaf_size (-l) will be ignored because --input_model_file"
- << " is specified." << endl;
if (CLI::HasParam("random_basis"))
Log::Warn << "--random_basis (-R) will be ignored because "
<< "--input_model_file is specified." << endl;
- if (CLI::HasParam("naive"))
- Log::Warn << "--naive (-N) will be ignored because --input_model_file is "
- << "specified." << endl;
+ // Notify the user of parameters that will be only be considered for query
+ // tree.
+ if (CLI::HasParam("leaf_size"))
+ Log::Warn << "--leaf_size (-l) will only be considered for the query tree,
+ "because --input_model_file is specified." << endl;
}
// The user should give something to do...
@@ -224,15 +223,19 @@ int main(int argc, char *argv[])
const string inputModelFile = CLI::GetParam<string>("input_model_file");
data::Load(inputModelFile, "kfn_model", kfn, true); // Fatal on failure.
+ knn.SingleMode() = CLI::HasParam("single_mode");
+ knn.Naive() = CLI::HasParam("naive");
+ knn.Epsilon() = epsilon;
+
+ // If leaf_size wasn't provided, let's consider the current value in the
+ // loaded model. Else, update it (only considered when building the query
+ // tree).
+ if (CLI::HasParam("leaf_size"))
+ knn.LeafSize() = size_t(lsInt);
+
Log::Info << "Loaded kFN model from '" << inputModelFile << "' (trained on "
<< kfn.Dataset().n_rows << "x" << kfn.Dataset().n_cols << " dataset)."
<< endl;
-
- // Adjust singleMode and naive if necessary.
- kfn.SingleMode() = CLI::HasParam("single_mode");
- kfn.Naive() = CLI::HasParam("naive");
- kfn.LeafSize() = size_t(lsInt);
- kfn.Epsilon() = epsilon;
}
// Perform search, if desired.
diff --git a/src/mlpack/methods/neighbor_search/knn_main.cpp b/src/mlpack/methods/neighbor_search/knn_main.cpp
index 90aaea6..a7e6b2a 100644
--- a/src/mlpack/methods/neighbor_search/knn_main.cpp
+++ b/src/mlpack/methods/neighbor_search/knn_main.cpp
@@ -119,24 +119,20 @@ int main(int argc, char *argv[])
if (CLI::HasParam("tree_type"))
Log::Warn << "--tree_type (-t) will be ignored because --input_model_file"
<< " is specified." << endl;
- if (CLI::HasParam("leaf_size"))
- Log::Warn << "--leaf_size (-l) will be ignored because --input_model_file"
- << " is specified." << endl;
- if (CLI::HasParam("tau"))
- Log::Warn << "--tau (-u) will be ignored because --input_model_file"
- << " is specified." << endl;
- if (CLI::HasParam("rho"))
- Log::Warn << "--rho (-b) will be ignored because --input_model_file"
- << " is specified." << endl;
if (CLI::HasParam("random_basis"))
Log::Warn << "--random_basis (-R) will be ignored because "
<< "--input_model_file is specified." << endl;
- if (CLI::HasParam("naive"))
- Log::Warn << "--naive (-N) will be ignored because --input_model_file is "
- << "specified." << endl;
- if (CLI::HasParam("single_mode"))
- Log::Warn << "--single_mode (-S) will be ignored because --input_model_file is "
- << "specified." << endl;
+ if (CLI::HasParam("tau"))
+ Log::Warn << "--tau (-u) will be ignored because --input_model_file is "
+ "specified." << endl;
+ if (CLI::HasParam("rho"))
+ Log::Warn << "--rho (-b) will be ignored because --input_model_file is "
+ "specified." << endl;
+ // Notify the user of parameters that will be only be considered for query
+ // tree.
+ if (CLI::HasParam("leaf_size"))
+ Log::Warn << "--leaf_size (-l) will only be considered for the query tree,
+ "because --input_model_file is specified." << endl;
}
// The user should give something to do...
@@ -246,6 +242,16 @@ int main(int argc, char *argv[])
const string inputModelFile = CLI::GetParam<string>("input_model_file");
data::Load(inputModelFile, "knn_model", knn, true); // Fatal on failure.
+ knn.SingleMode() = CLI::HasParam("single_mode");
+ knn.Naive() = CLI::HasParam("naive");
+ knn.Epsilon() = epsilon;
+
+ // If leaf_size wasn't provided, let's consider the current value in the
+ // loaded model. Else, update it (only considered when building the query
+ // tree).
+ if (CLI::HasParam("leaf_size"))
+ knn.LeafSize() = size_t(lsInt);
+
Log::Info << "Loaded kNN model from '" << inputModelFile << "' (trained on "
<< knn.Dataset().n_rows << "x" << knn.Dataset().n_cols << " dataset)."
<< endl;
More information about the mlpack-git
mailing list