简体   繁体   English

无法从 sklearn import c 导入

[英]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:我正在使用 jupyter notebook 进行 python 作业,我正在尝试从sklearn导入KNearestNeighbor ,但出现错误:

ImportError: cannot import name 'KNearestNeighbor' from 'sklearn' (C:\\Users\\michaelconway\\Anaconda3\\lib\\site-packages\\sklearn__init__.py)导入错误:无法从 'sklearn' (C:\\Users\\michaelconway\\Anaconda3\\lib\\site-packages\\sklearn__init__.py) 导入名称 'KNearestNeighbor'

I have checked and I do have sklearn installed: version 0.22我已经检查过并且确实安装了 sklearn:版本 0.22

Any ideas please?请问有什么想法吗?

I have never seen KNearestNeighbor in sklearn.我从未在KNearestNeighbor中见过 KNearestNeighbor。 There is two thing you can do instead of KNearestNeighbor你可以做两件事来代替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我认为第一个选项是您现在想要的选项

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如果您正在使用 jupyter notebook 进行 Python 作业,并且您尝试从 sklearn 导入 KNearestNeighbor,但出现错误: IMPORT ERROR
then try然后尝试

from sklearn.neighbors import NearestNeighbors

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM