paploo
paploo

Reputation: 173

Cannot import from sklearn import c

I am working on jupyter notebook on a python assignment and I am trying to import KNearestNeighbor from sklearn but I am getting the error:

ImportError: cannot import name 'KNearestNeighbor' from 'sklearn' (C:\Users\michaelconway\Anaconda3\lib\site-packages\sklearn__init__.py)

I have checked and I do have sklearn installed: version 0.22

Any ideas please?

Upvotes: 1

Views: 2217

Answers (2)

Ashish Sharma
Ashish Sharma

Reputation: 21

from sklearn.neighbors import KNeighborsClassifier

If you are working on jupyter notebook on a python assignment and you are trying to import KNearestNeighbor from sklearn but you are getting an error: IMPORT ERROR
then try

from sklearn.neighbors import NearestNeighbors

Upvotes: 0

Kalana
Kalana

Reputation: 6173

I have never seen KNearestNeighbor in sklearn. There is two thing you can do instead of KNearestNeighbor

  1. from sklearn.neighbors import KNeighborsClassifier

    or

  2. from sklearn.neighbors import NearestNeighbors

I think 1st option is the option which you want now

Upvotes: 3

Related Questions