ModuleNotFoundError:没有名为“numpy.testing.nosetester"的模块 [英] ModuleNotFoundError: No module named 'numpy.testing.nosetester'

查看:40
本文介绍了ModuleNotFoundError:没有名为“numpy.testing.nosetester"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用决策树时出现了这个错误.当我使用反向传播时,出现了同样的情况.我该如何解决?

将pandas导入为pd将 numpy 导入为 npa = np.test()f = open('E:/lgdata.csv')数据 = pd.read_csv(f,index_col = 'id')x = data.iloc[:,10:12].as_matrix().astype(int)y = data.iloc[:,9].as_matrix().astype(int)从 sklearn.tree 导入 DecisionTreeClassifier 作为 DTCdtc = DTC(criterion='entropy')dtc.fit(x,y)x=pd.DataFrame(x)从 sklearn.tree 导入 export_graphviz使用 open('tree.dot','w') 作为 f1:f1 = export_graphviz(dtc, feature_names = x.columns, out_file = f1)

<块引用>

回溯(最近一次调用最后一次):
文件<ipython-input-40-4359c06ae1f0>",第 1 行,在 <module>
runfile('C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib/_numpy_compat.py', wdir='C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib')
运行文件中的文件C:ProgramDataAnaconda3libsite-packagesspyderutilssitesitecustomize.py",第 710 行
execfile(文件名,命名空间)
文件C:ProgramDataAnaconda3libsite-packagesspyderutilssitesitecustomize.py",第 101 行,在 execfile
exec(compile(f.read(), filename, 'exec'), namespace)
文件C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib/_numpy_compat.py",第 9 行,<模块>
从 numpy.testing.nosetester 导入 import_nose

ModuleNotFoundError: 没有名为numpy.testing.nosetester"的模块

解决方案

这是由于 numpyscipy 之间的版本不兼容而导致的.numpy 在其最新版本中已弃用 numpy.testing.nosetester.

复制问题

pip install numpy==1.18 # >1.18pip install scipy<=0.19.0 # <= 0.19

from sklearn.tree import DecisionTreeClassifier as DTC

触发错误.

修复错误

将您的 scipy 升级到更高版本.

pip install numpy==1.18pip 安装 scipy==1.1.0pip 安装 scikit-learn==0.21.3

但不限于此.通过将上述库升级到最新的稳定版,您应该可以摆脱这个错误.

I was using the Decision Tree and this error was raised. The same situation appeared when I used Back Propagation. How can I solve it?

import pandas as pd
import numpy as np
a = np.test()
f = open('E:/lgdata.csv')
data = pd.read_csv(f,index_col = 'id')

x = data.iloc[:,10:12].as_matrix().astype(int)
y = data.iloc[:,9].as_matrix().astype(int)

from sklearn.tree import DecisionTreeClassifier as DTC
dtc = DTC(criterion='entropy')
dtc.fit(x,y)
x=pd.DataFrame(x) 

from sklearn.tree import export_graphviz
with open('tree.dot','w') as f1:
    f1 = export_graphviz(dtc, feature_names = x.columns, out_file = f1)

Traceback (most recent call last):
  File "<ipython-input-40-4359c06ae1f0>", line 1, in <module>
    runfile('C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib/_numpy_compat.py', wdir='C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib')
  File "C:ProgramDataAnaconda3libsite-packagesspyderutilssitesitecustomize.py", line 710, in runfile
    execfile(filename, namespace)
  File "C:ProgramDataAnaconda3libsite-packagesspyderutilssitesitecustomize.py", line 101, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)
  File "C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib/_numpy_compat.py", line 9, in <module>
    from numpy.testing.nosetester import import_nose

ModuleNotFoundError: No module named 'numpy.testing.nosetester'

解决方案

This is happening due to a version incompatibility between numpy and scipy. numpy in its latest versions have deprecated numpy.testing.nosetester.

Replicating the issue

pip install numpy==1.18 # > 1.18
pip install scipy<=0.19.0 # <= 0.19 

and

from sklearn.tree import DecisionTreeClassifier as DTC

Triggers the error.

Fixing the error

Upgrade your scipy to a higher version.

pip install numpy==1.18
pip install scipy==1.1.0
pip install scikit-learn==0.21.3

But not limited to this. By upgrading the above libraries to the latest stable, you should be able to get rid of this error.

这篇关于ModuleNotFoundError:没有名为“numpy.testing.nosetester"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆