我正在尝试使用train_test_split
函数并编写:
from sklearn.model_selection import train_test_split
这导致
ImportError: No module named model_selection
为什么?以及如何克服?
我想您的版本错误scikit-learn
,GitHub上也描述了类似的情况。之前(位于之前v0.18
)train_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] 删除。
我来说两句