【发布时间】:2020-07-30 02:09:40
【问题描述】:
这里 df 的形状是 (190,2),其中第一列是 x,是一个分类值,@nd 列是整数。
X = df.iloc[:,0].values
y = df.iloc[:,-1].values
# Encoding categorical data
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder = LabelEncoder()
X = labelencoder.fit_transform(X)
X.reshape(-1,1)
onehotencoder = OneHotEncoder(categories = [0])
X = onehotencoder.fit_transform(X).toarray()
在这里,我想使用 OneHotEncoder 更改分类值 X 来预测 y。但是当我运行这段代码时,我得到了一个错误。
ValueError: bad input shape ()
谁能帮我解决这个问题。谢谢
【问题讨论】:
标签: python machine-learning one-hot-encoding