Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FranciscusRenatus/19dcdecaa4a6b6638e5526eea6dcd48a to your computer and use it in GitHub Desktop.
Save FranciscusRenatus/19dcdecaa4a6b6638e5526eea6dcd48a to your computer and use it in GitHub Desktop.
# Encoding categorical data
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder = LabelEncoder()
X[:, 3] = labelencoder.fit_transform(X[:, 3])
onehotencoder = OneHotEncoder(categorical_features = [3])
X = onehotencoder.fit_transform(X).toarray()
# Avoiding the Dummy Variable Trap
X = X[:, 1:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment