<h4 dir="auto">Description</h4>

<p dir="auto"><code class="notranslate">sklearn.neighbors.NearestNeighbor</code> throws exceptions at me when I use <code class="notranslate">metric='seuclidean'</code>.  This seems to come down to a problem within <code class="notranslate">BallTree</code>, as it works normally if I set <code class="notranslate">algorithm='brute'</code>.</p>
<h4 dir="auto">Steps/Code to Reproduce</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
from sklearn.neighbors import NearestNeighbors

X = np.random.randn(5000, 4)
KNN = NearestNeighbors(metric='seuclidean', algorithm='auto')
KNN.fit(X)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">neighbors</span> <span class="pl-k">import</span> <span class="pl-v">NearestNeighbors</span>

<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-c1">5000</span>, <span class="pl-c1">4</span>)
<span class="pl-v">KNN</span> <span class="pl-c1">=</span> <span class="pl-v">NearestNeighbors</span>(<span class="pl-s1">metric</span><span class="pl-c1">=</span><span class="pl-s">'seuclidean'</span>, <span class="pl-s1">algorithm</span><span class="pl-c1">=</span><span class="pl-s">'auto'</span>)
<span class="pl-v">KNN</span>.<span class="pl-en">fit</span>(<span class="pl-v">X</span>)</pre></div>
<h4 dir="auto">Expected Results</h4>

<p dir="auto">It should work.</p>
<h4 dir="auto">Actual Results</h4>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-11-998055d5726c&gt; in &lt;module&gt;()
----&gt; 1 KNN.fit(X)

/home/bmcfee/miniconda/envs/py35/lib/python3.5/site-packages/sklearn/neighbors/base.py in fit(self, X, y)
    814             or [n_samples, n_samples] if metric='precomputed'.
    815         &quot;&quot;&quot;
--&gt; 816         return self._fit(X)

/home/bmcfee/miniconda/envs/py35/lib/python3.5/site-packages/sklearn/neighbors/base.py in _fit(self, X)
    256             self._tree = BallTree(X, self.leaf_size,
    257                                   metric=self.effective_metric_,
--&gt; 258                                   **self.effective_metric_params_)
    259         elif self._fit_method == 'kd_tree':
    260             self._tree = KDTree(X, self.leaf_size,

sklearn/neighbors/binary_tree.pxi in sklearn.neighbors.ball_tree.BinaryTree.__init__ (sklearn/neighbors/ball_tree.c:8381)()

sklearn/neighbors/dist_metrics.pyx in sklearn.neighbors.dist_metrics.DistanceMetric.get_metric (sklearn/neighbors/dist_metrics.c:4330)()

sklearn/neighbors/dist_metrics.pyx in sklearn.neighbors.dist_metrics.SEuclideanDistance.__init__ (sklearn/neighbors/dist_metrics.c:5888)()

TypeError: __init__() takes exactly 1 positional argument (0 given)"><pre class="notranslate"><code class="notranslate">---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-11-998055d5726c&gt; in &lt;module&gt;()
----&gt; 1 KNN.fit(X)

/home/bmcfee/miniconda/envs/py35/lib/python3.5/site-packages/sklearn/neighbors/base.py in fit(self, X, y)
    814             or [n_samples, n_samples] if metric='precomputed'.
    815         """
--&gt; 816         return self._fit(X)

/home/bmcfee/miniconda/envs/py35/lib/python3.5/site-packages/sklearn/neighbors/base.py in _fit(self, X)
    256             self._tree = BallTree(X, self.leaf_size,
    257                                   metric=self.effective_metric_,
--&gt; 258                                   **self.effective_metric_params_)
    259         elif self._fit_method == 'kd_tree':
    260             self._tree = KDTree(X, self.leaf_size,

sklearn/neighbors/binary_tree.pxi in sklearn.neighbors.ball_tree.BinaryTree.__init__ (sklearn/neighbors/ball_tree.c:8381)()

sklearn/neighbors/dist_metrics.pyx in sklearn.neighbors.dist_metrics.DistanceMetric.get_metric (sklearn/neighbors/dist_metrics.c:4330)()

sklearn/neighbors/dist_metrics.pyx in sklearn.neighbors.dist_metrics.SEuclideanDistance.__init__ (sklearn/neighbors/dist_metrics.c:5888)()

TypeError: __init__() takes exactly 1 positional argument (0 given)
</code></pre></div>
<h4 dir="auto">Versions</h4>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Linux-3.16.0-44-generic-x86_64-with-debian-jessie-sid
Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec  7 2015, 11:16:01) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
NumPy 1.10.2
SciPy 0.16.1
Scikit-Learn 0.17"><pre class="notranslate"><code class="notranslate">Linux-3.16.0-44-generic-x86_64-with-debian-jessie-sid
Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec  7 2015, 11:16:01) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
NumPy 1.10.2
SciPy 0.16.1
Scikit-Learn 0.17
</code></pre></div>
<p dir="auto">Here is a quick example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="dist = 'seuclidean' 
    D = pairwise_distances(X[:400,:], metric = dist )
    D = np.nan_to_num(D)
    eps = np.percentile(D, 0.6)
    print eps
    dscan = DBSCAN(eps=eps, min_samples=5, metric = dist)
    y = dscan.fit_predict(X)"><pre class="notranslate"><code class="notranslate">dist = 'seuclidean' 
    D = pairwise_distances(X[:400,:], metric = dist )
    D = np.nan_to_num(D)
    eps = np.percentile(D, 0.6)
    print eps
    dscan = DBSCAN(eps=eps, min_samples=5, metric = dist)
    y = dscan.fit_predict(X)
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  File &quot;cluster.py&quot;, line 91, in cluster
    y = dscan.fit_predict(X)
  File &quot;/usr/local/lib/python2.7/dist-packages/sklearn/base.py&quot;, line 345, in fit_predict
    self.fit(X)
  File &quot;/usr/local/lib/python2.7/dist-packages/sklearn/cluster/dbscan_.py&quot;, line 248, in fit
    clust = dbscan(X, **self.get_params())
  File &quot;/usr/local/lib/python2.7/dist-packages/sklearn/cluster/dbscan_.py&quot;, line 101, in dbscan
    neighbors_model.fit(X)
  File &quot;/usr/local/lib/python2.7/dist-packages/sklearn/neighbors/base.py&quot;, line 661, in fit
    return self._fit(X)
  File &quot;/usr/local/lib/python2.7/dist-packages/sklearn/neighbors/base.py&quot;, line 234, in _fit
    **self.effective_metric_params_)
  File &quot;binary_tree.pxi&quot;, line 1062, in sklearn.neighbors.ball_tree.BinaryTree.__init__ (sklearn/neighbors/ball_tree.c:8037)
  File &quot;dist_metrics.pyx&quot;, line 280, in sklearn.neighbors.dist_metrics.DistanceMetric.get_metric (sklearn/neighbors/dist_metrics.c:4066)
  File &quot;dist_metrics.pyx&quot;, line 435, in sklearn.neighbors.dist_metrics.SEuclideanDistance.__init__ (sklearn/neighbors/dist_metrics.c:5414)
TypeError: __init__() takes exactly 1 positional argument (0 given)"><pre class="notranslate"><code class="notranslate">  File "cluster.py", line 91, in cluster
    y = dscan.fit_predict(X)
  File "/usr/local/lib/python2.7/dist-packages/sklearn/base.py", line 345, in fit_predict
    self.fit(X)
  File "/usr/local/lib/python2.7/dist-packages/sklearn/cluster/dbscan_.py", line 248, in fit
    clust = dbscan(X, **self.get_params())
  File "/usr/local/lib/python2.7/dist-packages/sklearn/cluster/dbscan_.py", line 101, in dbscan
    neighbors_model.fit(X)
  File "/usr/local/lib/python2.7/dist-packages/sklearn/neighbors/base.py", line 661, in fit
    return self._fit(X)
  File "/usr/local/lib/python2.7/dist-packages/sklearn/neighbors/base.py", line 234, in _fit
    **self.effective_metric_params_)
  File "binary_tree.pxi", line 1062, in sklearn.neighbors.ball_tree.BinaryTree.__init__ (sklearn/neighbors/ball_tree.c:8037)
  File "dist_metrics.pyx", line 280, in sklearn.neighbors.dist_metrics.DistanceMetric.get_metric (sklearn/neighbors/dist_metrics.c:4066)
  File "dist_metrics.pyx", line 435, in sklearn.neighbors.dist_metrics.SEuclideanDistance.__init__ (sklearn/neighbors/dist_metrics.c:5414)
TypeError: __init__() takes exactly 1 positional argument (0 given)
</code></pre></div>
<p dir="auto">If I calculate distance matrix with it, the everything is just fine, but I want to use kd_tree or something to speed things up.</p>