DataConversionWarning:预期使用1d数组时传递了列向量y,请将y的形状更改为(n_samples,)

时间:2019-03-20 16:03:52

标签: python python-3.x

运行项目时出现上述错误,但我不确定为什么。代码如下:

X = IrisData.iloc[:,[0,1,2,3]].values
Y = IrisData.iloc[:,[4]].values

from sklearn.model_selection import train_test_split
X_TrainSet, X_TestSet, Y_TrainSet, Y_TestSet = train_test_split(X, Y)


from sklearn.neighbors import KNeighborsClassifier
ForClassification = KNeighborsClassifier(n_neighbors=6)
ForClassification.fit(X_TrainSet, Y_TrainSet)

Running the last set, I get this error:

DataConversionWarning:当期望1d数组时,传递了列向量y。请从sys.path中删除cwd之后,例如使用ravel()将y的形状更改为(n_samples,)。

似乎可以产生结果,但是可以继续吗?

0 个答案:

没有答案