(1)运行Windows 8 (2)下载并安装,Anaconda for Windows,PYTHON 2.7
(3)来自Anaconda提示:
conda install scikit-learn
Fetching package metadata: ....
Solving package specifications: .....................
All requested packages already installed.
packages in environment at C:\Users\Joey\Anaconda2:
scikit-learn 0.17 np110py27_1
(4)推出Spyder
(5)没关系,找到包裹。
import sklearn
(6)sklearn的Tab完成(在Spyder中),显示:
sklearn.base
sklearn.clone
sklearn.externals
sklearn.re
sklearn.setup_module
sklearn.sys
sklearn.utils
sklearn.warnings
(6)因此,在运行http://scikit-learn.org/stable/示例中的代码段时。
from sklearn import DecisionTreeRegressor
Traceback (most recent call last):
File "<ipython-input-2-5aa62260685f>", line 1, in <module>
from sklearn import DecisionTreeRegressor
ImportError: cannot import name DecisionTreeRegressor
(7) 早些时候,我注意到使用Enthought Canopy的相同行为,也无法让scikit在那里工作。结果,我卸载了每个Python程序和IDE,我可以在尝试Anaconda之前尝试清理我的系统,如上所述。我查看了许多其他帖子,仍然无法使我的系统正常工作并怀疑其路径,库或版本问题。
答案 0 :(得分:3)
正确的方法是:
from sklearn.tree import DecisionTreeRegressor
sklearn。版本 = 0.17
答案 1 :(得分:0)
scikit-learn有详细记录。以下是文档的link。
答案 2 :(得分:0)
from sklearn.tree import DecisionTreeRegressor