gpt4 book ai didi

python - 需要解压的值太多(预计有 3 个)

转载 作者:行者123 更新时间:2023-12-01 07:18:22 33 4
gpt4 key购买 nike

使用 python 将数据拆分为训练和测试时,出现以下错误

" too many values to unpack (expected 3)"

这是我的代码:

from sklearn.model_selection import train_test_split
X_train, X_test, y_train = train_test_split(features,prices, test_size=0.2, random_state=10)
print("Training and testing split was succesful")

这是预期的输出:“训练和测试拆分成功”

最佳答案

看来您错过了 y_test。

试试这个:

X_train, X_test, y_train, y_test = train_test_split(features,prices, test_size=0.2, random_state=10) 

关于python - 需要解压的值太多(预计有 3 个),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57839230/

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