[mlpack-git] master: Fix output and documentation. (11326ef)

gitdub at mlpack.org gitdub at mlpack.org
Tue Oct 25 04:44:53 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/31995784e651e1c17c988c79d9f53c9dbad620f8...81fce4edfc8bfb4c26b48ed388f559ec1cee26dd

>---------------------------------------------------------------

commit 11326ef212e0982f611a40f6a1261651f654db8b
Author: Ryan Curtin <ryan at ratml.org>
Date:   Tue Oct 25 04:44:53 2016 -0400

    Fix output and documentation.
    
    Also ensure that error is computed when a file is supplied.


>---------------------------------------------------------------

11326ef212e0982f611a40f6a1261651f654db8b
 src/mlpack/methods/approx_kfn/approx_kfn_main.cpp | 30 ++++++++++++++---------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/mlpack/methods/approx_kfn/approx_kfn_main.cpp b/src/mlpack/methods/approx_kfn/approx_kfn_main.cpp
index b5f2ac2..97de7c5 100644
--- a/src/mlpack/methods/approx_kfn/approx_kfn_main.cpp
+++ b/src/mlpack/methods/approx_kfn/approx_kfn_main.cpp
@@ -68,8 +68,8 @@ PARAM_STRING_IN("neighbors_file", "File to save furthest neighbor indices to.",
 PARAM_STRING_IN("distances_file", "File to save furthest neighbor distances to.",
     "d", "");
 
-PARAM_FLAG("calculate_error", "If set, calculate the average distance error.",
-    "e");
+PARAM_FLAG("calculate_error", "If set, calculate the average distance error for"
+    " the first furthest neighbor only.", "e");
 PARAM_STRING_IN("exact_distances_file", "File containing exact distances to "
     "furthest neighbors; this can be used to avoid explicit calculation when "
     "--calculate_error is set.", "x", "");
@@ -178,6 +178,7 @@ int main(int argc, char** argv)
       m.qdafn = QDAFN<>(referenceSet, numTables, numProjections);
       Timer::Stop("qdafn_construct");
     }
+    Log::Info << "Model built." << endl;
   }
   else
   {
@@ -205,15 +206,20 @@ int main(int argc, char** argv)
     if (m.type == 0)
     {
       Timer::Start("drusilla_select_search");
+      Log::Info << "Searching for " << k << " furthest neighbors with "
+          << "DrusillaSelect..." << endl;
       m.ds.Search(set, k, neighbors, distances);
       Timer::Stop("drusilla_select_search");
     }
     else
     {
       Timer::Start("qdafn_search");
+      Log::Info << "Searching for " << k << " furthest neighbors with "
+          << "QDAFN..." << endl;
       m.qdafn.Search(set, k, neighbors, distances);
       Timer::Stop("qdafn_search");
     }
+    Log::Info << "Search complete." << endl;
 
     // Should we calculate error?
     if (CLI::HasParam("calculate_error"))
@@ -228,19 +234,21 @@ int main(int argc, char** argv)
       {
         // Calculate exact distances.  We are guaranteed the reference set is
         // available.
+        Log::Info << "Calculating exact distances..." << endl;
         AllkFN kfn(referenceSet);
         arma::Mat<size_t> exactNeighbors;
-        kfn.Search(set, k, exactNeighbors, exactDistances);
+        kfn.Search(set, 1, exactNeighbors, exactDistances);
+        Log::Info << "Calculation complete." << endl;
+      }
 
-        const double averageError = arma::sum(exactDistances / distances.row(0))
-            / distances.n_cols;
-        const double minError = arma::min(exactDistances / distances.row(0));
-        const double maxError = arma::max(exactDistances / distances.row(0));
+      const double averageError = arma::sum(exactDistances / distances.row(0)) /
+          distances.n_cols;
+      const double minError = arma::min(exactDistances / distances.row(0));
+      const double maxError = arma::max(exactDistances / distances.row(0));
 
-        Log::Info << "Average error: " << averageError << "." << endl;
-        Log::Info << "Maximum error: " << maxError << "." << endl;
-        Log::Info << "Minimum error: " << minError << "." << endl;
-      }
+      Log::Info << "Average error: " << averageError << "." << endl;
+      Log::Info << "Maximum error: " << maxError << "." << endl;
+      Log::Info << "Minimum error: " << minError << "." << endl;
     }
 
     // Save results, if desired.




More information about the mlpack-git mailing list