ImportError:没有名为model_selection的模块

点心:

我正在尝试使用train_test_split函数并编写:

from sklearn.model_selection import train_test_split

这导致

ImportError: No module named model_selection

为什么?以及如何克服?

linusg:

我想您的版本错误scikit-learnGitHub上也描述了类似的情况之前(位于之前v0.18train_test_split位于cross_validation模块中:

from sklearn.cross_validation import train_test_split

但是,现在它在model_selection模块中:

from sklearn.model_selection import train_test_split

因此您需要最新版本。

要升级到至少版本0.18,请执行以下操作:

pip install -U scikit-learn

(或者pip3,取决于您的Python版本)。如果以其他方式安装了它,请确保使用其他方法进行更新,例如在使用Anaconda时。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章