computersciencer 2021-08-09 23:14 采纳率: 83.3%
浏览 289
已结题

请用力解决问题:python机器学习报错

我写的代码文件findKNNKValue.py的79行代码如下:
from sklearn import neighbors
运行程序后,报错信息如下:
Traceback (most recent call last):
File "E:\script\logisticsWeb\logisticsWeb\siteAnsys\findKNNKValue.py", line 79, in
from sklearn import neighbors
File "e:\anaconda3\lib\site-packages\sklearn_init_.py", line 82, in
from .base import clone
File "e:\anaconda3\lib\site-packages\sklearn\base.py", line 17, in
from .utils import IS_32BIT
File "e:\anaconda3\lib\site-packages\sklearn\utils_init
.py", line 23, in
from .class_weight import compute_class_weight, compute_sample_weight
File "e:\anaconda3\lib\site-packages\sklearn\utils\class_weight.py", line 7, in
from .validation import deprecate_positional_args
File "e:\anaconda3\lib\site-packages\sklearn\utils\validation.py", line 26, in
from .fixes import object_dtype_isnan, parse_version
File "e:\anaconda3\lib\site-packages\sklearn\utils\fixes.py", line 20, in
import scipy.stats
File "e:\anaconda3\lib\site-packages\scipy\stats_init
.py", line 391, in
from .stats import *
File "e:\anaconda3\lib\site-packages\scipy\stats\stats.py", line 174, in
from scipy.spatial.distance import cdist
File "e:\anaconda3\lib\site-packages\scipy\spatial_init
.py", line 102, in
from .geometric_slerp import geometric_slerp
File "e:\anaconda3\lib\site-packages\scipy\spatial_geometric_slerp.py", line 8, in
from scipy.spatial.distance import euclidean
File "e:\anaconda3\lib\site-packages\scipy\spatial\distance.py", line 122, in
from ..special import rel_entr
File "e:\anaconda3\lib\site-packages\scipy\special_init
.py", line 633, in
from . import _ufuncs
ImportError: cannot import name 'ufuncs' from partially initialized module 'scipy.special' (most likely due to a circular import) (e:\anaconda3\lib\site-packages\scipy\special_init.py)
请问怎么解决?

  • 写回答

1条回答 默认 最新

  • CSDN专家-HGJ 2021-08-09 23:38
    关注

    思路和建议:一是将第79行导入方式改成 from sklearn.neighbors import NearestNeighbors,代码其他原来用neighbors地方作相应修改。二是在anaconda中升级scipy

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 8月18日
  • 已采纳回答 8月10日
  • 创建了问题 8月9日

悬赏问题

  • ¥45 工程软件单片机设计课题要求
  • ¥15 在centos7安装conda
  • ¥15 c#调用yolo3 dll文件获取的数据对不上
  • ¥20 WPF 如何实现多语言,label 和cs(live Charts)中是否都能翻译
  • ¥15 STM32F103上电短路问题
  • ¥15 关于#单片机#的问题:以ATMEGA128或相近型号单片机为控制器设计直流电机调速的闭环控制系统(相关搜索:设计报告|软件设计|流程图)
  • ¥15 打开软件提示错误:failed to get wglChoosePixelFormatARB
  • ¥15 (标签-python|关键词-char)
  • ¥15 python+selenium,在新增时弹出了一个输入框
  • ¥15 苹果验机结果的api接口哪里有??单次调用1毛钱及以下。