[mlpack-git] master: Properly count the number of cases when calculating the effective error in approximate nearest neighbor search. (69804c6)

gitdub at mlpack.org gitdub at mlpack.org
Fri Aug 12 11:55:27 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/0f4b25acd6aaa14294c044874ba6cc0751712baa...0a19d07bd39e6223991976474bc79671ba8aa0f0

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

commit 69804c65f972dfa71be1933ef5d49723baccfb00
Author: MarcosPividori <marcos.pividori at gmail.com>
Date:   Thu Aug 11 19:47:49 2016 -0300

    Properly count the number of cases when calculating the effective error in
    approximate nearest neighbor search.


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

69804c65f972dfa71be1933ef5d49723baccfb00
 src/mlpack/methods/neighbor_search/knn_main.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/methods/neighbor_search/knn_main.cpp b/src/mlpack/methods/neighbor_search/knn_main.cpp
index 32fe239..391a303 100644
--- a/src/mlpack/methods/neighbor_search/knn_main.cpp
+++ b/src/mlpack/methods/neighbor_search/knn_main.cpp
@@ -305,13 +305,18 @@ int main(int argc, char *argv[])
           << "values than the set of distances being queried!" << endl;
 
       double effectiveError = 0;
+      size_t cases = 0;
       for (size_t i = 0; i < distances.n_elem; i++)
       {
         if (distancesExact(i) != 0 && distances(i) != DBL_MAX)
+        {
           effectiveError += (distances(i) - distancesExact(i)) /
               distancesExact(i);
+          cases++;
+        }
       }
-      effectiveError /= distances.n_elem;
+      if (cases)
+        effectiveError /= cases;
 
       Log::Info << "Effective error: " << effectiveError << endl;
     }




More information about the mlpack-git mailing list