📌  相关文章
📜  OneHotEncoder(categorical_features= - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:22.540000             🧑  作者: Mango

代码示例1
#Encoding the categorical data
from sklearn.preprocessing import LabelEncoder

labelencoder_X = LabelEncoder()
X[:,0] = labelencoder_X.fit_transform(X[:,0])

#we are dummy encoding as the machine learning algorithms will be
#confused with the values like Spain > Germany > France
from sklearn.preprocessing import OneHotEncoder

onehotencoder = OneHotEncoder(categorical_features=[0])
X = onehotencoder.fit_transform(X).toarray()