为什么在使用 numpy 1.13.3 时从 scipy 导入“梳子”会失败?

dEB*_*A M 2 numpy scipy python-3.x scikit-learn google-colaboratory

我正在研究 Google 协作中的特征选择和分类问题。我能够使用 numpy 1.11.3 版执行该程序。不幸的是,今天我在使用 numpy(1.13.3) 时遇到了一个错误,因为 scipy 在协作中不再支持 1.11.3。我正在使用 numpy 1.11.3,因为它对我有用,尽管它可能很旧。似乎不能再在python环境中导入'comb'。如何使用较新版本的 numpy 进行此操作?另外,我如何以及在哪里检查将来可能出现的其他库的此类不兼容问题?

我尝试手动输入“from scipy.misc import comb”和“from scipy import comb”,但它仍然不起作用。

import numpy as np
from sklearn.feature_selection import SelectPercentile, f_classif
from time import time

np.seterr(divide='ignore', invalid='ignore');
selector=SelectPercentile(f_classif , percentile = 8)
t0 = time()
X_newDoS = selector.fit_transform(X_DoS,Y_DoS)
print ('Time =', time() - t0)
Run Code Online (Sandbox Code Playgroud)

我收到的错误消息是:“ImportError: cannot import name 'comb'”

eri*_*.li 6

根据 scipy 的文档,

from scipy.misc import comb 
Run Code Online (Sandbox Code Playgroud)

自 1.0.0 版起已弃用。应该使用

from scipy.special import comb 
Run Code Online (Sandbox Code Playgroud)

反而。

https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.comb.html