[英]from ..utils.fixes import rankdata ImportError: cannot import name 'rankdata' MongoDB
I am trying to run Skikit learn through Spyder on Anaconda 我正在尝试在Anaconda上通过Spyder运行Skikit学习
C:\Anaconda3>conda --version
conda 4.3.4
C:\Anaconda3>python --version
Python 3.5.2 :: Anaconda 4.0.0 (64-bit)
Spyder 2.3.8
I try to do the following: 我尝试执行以下操作:
print("Scikit-Learn", sklearn.__version__)
NameError: name 'sklearn' is not defined
from sklearn.model_selection import *
from ..utils.fixes import rankdata
ImportError: cannot import name 'rankdata'
Errors
Any idea why this error is coming as in Anaconda it shows the package as present but when I run through Spyder it gives the above error. 知道为什么会出现此错误,就像在Anaconda中一样,它显示了该软件包的存在,但是当我运行Spyder时,它给出了以上错误。
As you are using anaconda try: 当您使用水蟒时,请尝试:
conda update scikit-learn
Conda will try to handle de dependences and it may update other packages. Conda将尝试处理依赖关系,并且可能会更新其他软件包。
If this does not work, in the file fixes.py located in <Anaconda_basedir>\\lib\\python3.5\\site-packages\\sklearn\\utils
there is a line if sp_version < (0,13, 0):
which conditions the import of rankdata
if the version of scipy is lower than 0.13.0. 如果这不起作用,则位于
<Anaconda_basedir>\\lib\\python3.5\\site-packages\\sklearn\\utils
中的if sp_version < (0,13, 0):
)中有一行if sp_version < (0,13, 0):
这将限制导入如果rankdata
的版本低于0.13.0,则为rankdata。
For som reason, if the version is > 0.13.0 it should use the rankdata
from scipy.stats
. 出于某种原因,如果版本> 0.13.0,则应使用
rankdata
的scipy.stats
。 But, at least in my case it wasn't, what I did was to add a and False
so it gets the rankdata
from scipy
. 但是,至少在我的情况不是这样,我所做的就是添加
and False
因此它的rankdata
从scipy
。
The final line is: 最后一行是:
...
if sp_version < (0, 13, 0) and False:
def rankdata(a, method='average'):
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.