-1

guys am having import error while trying to import KNeighborsClassifier from sklearn.neighbors import k

its showing the following errors

ImportError: cannot import name 'kNeighborsClassifier' from 'sklearn.neighbors' (/home/themysteriouschemeng/anaconda3/lib/python3.7/site-packages/sklearn/neighbors/init.py)

Abdulrahman Isah
  • 19
  • 1
  • 2
  • 4
  • Trying to edit the *answer* in order to add (images of) your code is the absolutely wrong thing to do here and not how SO works. Please edit your own question instead. – desertnaut Jul 08 '20 at 19:30

2 Answers2

1

You have used small k instead of capital K in KNeighborsClassifier.

Your import -from sklearn.neighbors import kNeighborsClassifier

Right import - from sklearn.neighbors import KNeighborsClassifier

Replace small k with capital K in KNeighborsClassifier and this will fix your import issue.

Sandeep Panchal
  • 385
  • 2
  • 3
0

Can you add the code you are using?

Btw the basic code to import is

from sklearn.neighbors import KNeighborsClassifier

model = KNeighborsClassifier(n_neighbors=4)
desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • from sklearn.neighbors import KNeighborsClassifier it shows the following errorImportError: cannot import name 'kNeighborsClassifier' from 'sklearn.neighbors' (/home/themysteriouschemeng/anaconda3/lib/python3.7/site-packages/sklearn/neighbors/__init__.py) – Abdulrahman Isah Jul 08 '20 at 20:54