ImportError:无法导入名称VarianceThreshold

2024-05-19 17:03:37 发布

您现在位置:Python中文网/ 问答频道 /正文

scikit learn似乎很管用,但当我这么做的时候:

from sklearn.feature_selection import VarianceThreshold

我得到了以下错误:

ImportError: cannot import name VarianceThreshold

如何绕过这个?我是Python的新手,所以我不知道该怎么做。在

我玩弄了我的进口商品的顺序,正如这里所建议的:ImportError: Cannot import name X,但没有运气。在

^{pr2}$

我也得到了这个:

code/python/k_means/serial_version$ python -c 'import sklearn; print(sklearn.VarianceThreshold)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'VarianceThreshold'

版本:

>>> import sklearn
>>> sklearn.__version__
'0.14.1'

Tags: namefromimportversion错误sklearnscikitlearn
1条回答
网友
1楼 · 发布于 2024-05-19 17:03:37

您可以通过捕捉异常来绕过

try:
    from sklearn.feature_selection import VarianceThreshold
except:
    pass  # it will catch any exception here

如果只想捕获属性错误异常,请使用下面的方法

^{pr2}$

相关问题 更多 >