【发布时间】:2016-05-16 04:56:22
【问题描述】:
scikit-learn 似乎可以工作,但是当我这样做时:
from sklearn.feature_selection import VarianceThreshold
我收到以下错误:
ImportError: 无法导入名称 VarianceThreshold
如何绕过这个?我是 Python 的新手,所以我不知道该怎么做。
按照此处的建议,我使用了我的导入顺序:ImportError: Cannot import name X,但没有运气。
import sys
import pandas as pd
import numpy as np
import operator
from sklearn.feature_selection import VarianceThreshold
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.feature_extraction.text import HashingVectorizer
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.preprocessing import normalize
from sklearn import decomposition
我也得到了这个:
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'
【问题讨论】:
-
这里有同样的问题。你在什么操作系统上?
-
@GeorgeWS 发帖时我使用的是 Ubuntu 14.04,64 位。
-
好的。这昨天在 Ubuntu 14.04.4 上为我工作,但现在无法通过 ssh 进入 Mac OS X 10.11.4 的同一台机器。
-
@GeorgeWS 我完全不知道您为什么会遇到问题。您可以发布一个新问题或,如果您认为我的问题可以扩展,您应该悬赏并编辑我的问题。
-
我可能认识@GeorgeWS!既然你提到了它,那时我的项目的截止日期就快到了,所以不,我继续前进。可能这仍然是一个活跃的问题......
标签: python python-2.7 machine-learning scikit-learn bigdata