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

标签 python logistic-regression

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

相关文章:

python - 建模支持向量回归 (SVR) 与线性回归

python - 高级切片。高阶切片/选择

python - 从 Pandas Dataframe Column 中删除重复的逗号换句话说,我只需要列中的文本用逗号分隔它们

python - 使用 MNIST 实现逻辑回归 - 不收敛?

python - 使用 sklearn 进行逻辑回归

python - Python 中的回归总结

optimization - 多类 Logistic 回归的学习曲线

python - 迭代次数达到限制的收敛警告 : lbfgs failed to converge (status=1): STOP: TOTAL NO.

python - 不能定义 2 是否为质数

python - 尝试在 python 中绘制颜色图