我正在使用OneHotEncoder进行转换。实现了愿望转换fromsklearn.preprocessingimportLabelEncoder
X[:,0] = labelencoder_X.fit_transform(X[:,0])
#we are dummy encoding as the machinelea
我先使用LabelEncoder,然后使用OneHotEncoder,尝试将分类值(在我的示例中是country列)转换为编码值,并且能够转换分类值。pandas as pdfromsklearn.preprocessingimportLabelEncoder, OneHotEncoder
#X is[:,0]) #LabelEncoder is us