Created
June 23, 2017 15:24
-
-
Save FranciscusRenatus/19dcdecaa4a6b6638e5526eea6dcd48a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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