使用 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/