[mlpack-svn] r15760 - mlpack/conf/jenkins-conf/benchmark/methods/scikit

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Sep 11 16:10:36 EDT 2013


Author: rcurtin
Date: Wed Sep 11 16:10:36 2013
New Revision: 15760

Log:
sklearn returns the self-neighbor, so increment k by one if the reference set is the query set.


Modified:
   mlpack/conf/jenkins-conf/benchmark/methods/scikit/allknn.py

Modified: mlpack/conf/jenkins-conf/benchmark/methods/scikit/allknn.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/methods/scikit/allknn.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/methods/scikit/allknn.py	Wed Sep 11 16:10:36 2013
@@ -94,7 +94,10 @@
           if len(self.dataset) == 2:
             out = model.kneighbors(queryData, k, return_distance=True)
           else:
-            out = model.kneighbors(referenceData, k, return_distance=True)
+	    # We have to increment k by one because mlpack ignores the
+	    # self-neighbor, whereas scikit-learn will happily return the
+	    # nearest neighbor of point 0 as point 0.
+            out = model.kneighbors(referenceData, k + 1, return_distance=True)
         except Exception as e:
           q.put(-1)
           return -1



More information about the mlpack-svn mailing list