本文介绍了导入错误:没有名为 sklearn.cross_validation 的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 14.04 中使用 python 2.7.我使用以下命令安装了 scikit-learn、numpy 和 matplotlib:

I am using python 2.7 in Ubuntu 14.04. I installed scikit-learn, numpy and matplotlib with these commands:

sudo apt-get install build-essential python-dev python-numpy \
python-numpy-dev python-scipy libatlas-dev g++ python-matplotlib \
ipython

但是当我导入这些包时:

But when I import these packages:

from sklearn.cross_validation import train_test_split

它返回给我这个错误:

ImportError: No module named sklearn.cross_validation

我需要做什么?

推荐答案

它必须与 cross_validation 子模块重命名和弃用 model_selection 相关.尝试将 cross_validation 替换为 model_selection

It must relate to the renaming and deprecation of cross_validation sub-module to model_selection. Try substituting cross_validation to model_selection

这篇关于导入错误:没有名为 sklearn.cross_validation 的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 10:48