python:import sklearn 报错:numpy.core.multiarray failed to import

文章讲述了如何处理numpy的安装问题,建议先卸载带mkl的numpy,再通过pip安装普通版本的numpy。同时,对于在使用sklearn的KNN函数时遇到的FutureWarning,给出了具体的解决办法,即关于mode函数在SciPy新版本中默认行为改变的适应策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

处理办法:
删除原有的numpy。一开始按照其他人的教程安装的numpy+mkl

pip uninstall numpy

重新使用pip命令安装新的numpy即可

pip install numpy

也就是不使用numpy+mkl 而是使用numpy

但是在使用sklearn中的KNN函数时会有警告提示:
FutureWarning: Unlike other reduction functions (e.g. skew, kurtosis), the default behavior of mode typically preserves the axis it acts along. In SciPy 1.11.0, this behavior will change: the default value of keepdims will become False, the axis over which the statistic is taken will be eliminated, and the value None will no longer be accepted. Set keepdims to True or False to avoid this warning.
mode, _ = stats.mode(_y[neigh_ind, k], axis=1)
处理办法:https://blog.csdn.net/weixin_51723388/article/details/128577782

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值