为什么我的sklearn库中的分类功能返回了意外的关键字参数?

时间:2018-12-23 21:35:13

标签: python categorical-data sklearn-pandas one-hot-encoding

from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_X =  LabelEncoder()
X[:, 0] = labelencoder_X.fit_transform(X[:, 0]) 
onehotencoder = OneHotEncoder(categorical_feature = [0])
X = onehotencoder.fit_transform(X).toarray()

错误在第四行,是的,我三遍检查了我的拼写

1 个答案:

答案 0 :(得分:1)

from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_X =  LabelEncoder()
X[:, 0] = labelencoder_X.fit_transform(X[:, 0]) 
onehotencoder = OneHotEncoder(categorical_feature = [0])
X = onehotencoder.fit_transform(X).toarray()

您可能在categorical_features争论中错过了一个“ s”。