无法从 0.20 版中的 sklearn 导入cross_validation >



当我从sklearn:导入cross_validation

from sklearn import cross_validation

我得到以下错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'cross_validation' from 'sklearn' (/root/anaconda3/lib/python3.7/site-packages/sklearn/__init__.py)

您必须将其称为

from sklearn.model_selection import cross_validate

如果你想进行列车测试拆分,你需要给出以下内容

from sklearn.model_selection import train_test_split
a_train, a_test, b_train, b_test = train_test_split(a, b, 
test_size=0.33, random_state=42)

sklearn中的交叉验证列车测试拆分已折旧

from sklearn.cross_validation import train_test_split

自版本0.18以来已弃用:此模块将在0.20中删除。使用sklearn.model_selection.train_testrongplit代替

相关内容

  • 没有找到相关文章

最新更新