Python错误:无法导入名称cross_validation

时间:2019-05-17 12:49:55

标签: python python-2.7 import data-science

我尝试通过在python 2中使用以下语句导入cross_validation

from sklearn import cross_validation

但是我收到以下错误

  

无法导入名称cross_validation

1 个答案:

答案 0 :(得分:1)

cross_validation在SKlearn 0.20中已删除。您现在可以将其导入为

from sklearn.model_selection import cross_validate

基本上所有与交叉验证相关的功能都在SKlearn的model_selection下移动。

编辑:

要导入train_test_split,

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)