“TypeError:Singleton数组不能被视为有效集合”,使用sklearn train_test_spli

2024-04-24 23:23:08 发布

您现在位置:Python中文网/ 问答频道 /正文

TypeError:不能将Singleton数组(0.2)视为有效的集合。

X = df.iloc[:, [1,7]].values
y= df.iloc[:,-1].values
from sklearn.model_selection import train_test_split 
X_train, X_test, y_train, y_test = train_test_split(X, y, 0.2)

我在尝试训练时遇到这个错误。我能用X和y值训练我的模型。不过,我想分割我的数据帧,然后训练和测试它。

如有任何帮助,我们将不胜感激。


Tags: fromtestimportdfmodel错误train数组