I'm trying to do:
from sklearn.model_selection import cross_validate
as mentioned here. But get the error:
ImportError: cannot import name 'cross_validate'
Everything else in Sklearn seems to work fine, it's just this bit. Error even occurs when I run this one line and nothing else.
答案 0 :(得分:19)
cross-validate
是版本0.19.0(change log)中的新内容:
交叉验证现在能够从多个结果返回结果 指标评估。新的model_selection.cross_validate可以返回 测试数据以及训练集性能和评分 时间安排,我们已经扩展了评分和改装参数 网格/随机搜索来处理多个指标。
如果您使用conda或conda upgrade scikit-learn
,为了使用它,请使用pip install --upgrade scikit-learn
更新您的scikit-learn安装。如果无法更新,您仍然可以使用cross_val_score
。
答案 1 :(得分:11)
在最新的稳定版本0.20.0上,它位于model_selection
下。
from sklearn.model_selection import train_test_split
答案 2 :(得分:0)
从sklearn.model_selection导入cross_validate