gpt4 book ai didi

python - 无法从版本 > 0.20 的 sklearn 导入 cross_validation

转载 作者:行者123 更新时间:2023-12-02 20:11:32 26 4
gpt4 key购买 nike

当我导入cross_validation时来自sklearn :

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

如果您想做train test splitting,您需要提供以下信息

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

Deprecated since version 0.18: This module will be removed in 0.20. Use sklearn.model_selection.train_test_split instead

关于python - 无法从版本 > 0.20 的 sklearn 导入 cross_validation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53515954/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com