Elffuss BraidHub

kikocis/auto-code-rover public

main · 747 BRawPermalink
1Missing parameter validation in Neighbors estimator for float n_neighbors
2```python
3from sklearn.neighbors import NearestNeighbors
4from sklearn.datasets import make_blobs
5X, y = make_blobs()
6neighbors = NearestNeighbors(n_neighbors=3.)
7neighbors.fit(X)
8neighbors.kneighbors(X)
9```
10```
11~/checkout/scikit-learn/sklearn/neighbors/binary_tree.pxi in sklearn.neighbors.kd_tree.NeighborsHeap.__init__()
12
13TypeError: 'float' object cannot be interpreted as an integer
14```
15This should be caught earlier and a more helpful error message should be raised (or we could be lenient and cast to integer, but I think a better error might be better).
16
17We need to make sure that
18```python
19neighbors.kneighbors(X, n_neighbors=3.)
20```
21also works.