我正在尝试调整来自numberOne
和numberTwo
的值,以便它适合LabelEncoder
,我稍后将其用于train_test_split
数据。但是我收到以下错误:
'bad input shape ()' It seems that the problem is on line le.fit(X)
我的代码:
from sklearn.cross_validation import train_test_split
from sklearn.preprocessing import LabelEncoder
numberOne = 9
numberTwo = 1
X = numberOne
y = numberTwo
le = preprocessing.LabelEncoder()
le.fit(X)
X = le.transform
print X
le = preprocessing.LabelEncoder()
le.fit(y)
y = le.transform
print y
答案 0 :(得分:1)
正如@Kevin在评论中所说,fit
将列表作为输入,或者最好是NumPy数组,而不是标量。