ImportError: cannot import name model_selection

ImportError: cannot import name model_selection

我正在尝试使用 iris 数据集学习数据分析。所以我只是复制已经为这个主题编写的代码,但我收到以下关于库的错误:

Traceback (most recent call last):
  File "iris.py", line 6, in <module>
    from sklearn import model_selection
ImportError: cannot import name model_selection

下面是我如何导入这个模块: from sklearn import model_selection

我正在使用 python 2.7, 可能是什么问题呢? 我怀疑是不是版本有问题!对不对?

请不要推荐Anaconda,我不愿意用

非常感谢

sklearn.model_selection 适用于 0.18 版或更高版本

Please update your sklearn by pip or other tools 

org 网站 http://scikit-learn.org/stable/whats_new.html#version-0-18

版本 0.18

2016 年 9 月 28 日 最新版本 Python 2.6 支持 Scikit-learn 0.18 将是支持 Python 2.6 的最后一个 scikit-learn 版本。更高版本的 scikit-learn 将需要 Python 2.7 或更高版本。 模型选择增强和 API 更改

model_selection模块 新模块 sklearn.model_selection 将以前 sklearn.cross_validation、sklearn.grid_search 和 sklearn.learning_curve 的功能组合在一起,引入了新的可能性,例如嵌套交叉验证和更好地操纵参数搜索Pandas。 许多事情将保持不变,但存在一些关键差异。阅读下文以了解有关更改的更多信息。 支持嵌套交叉验证的数据独立 CV 拆分器