Last active
June 24, 2017 11:20
-
-
Save FranciscusRenatus/224d1b3ec257246af325c3012816da2a 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 | |
# Encoding the Independent Variable | |
from sklearn.preprocessing import LabelEncoder, OneHotEncoder | |
labelencoder_X = LabelEncoder() | |
X[:, 0] = labelencoder_X.fit_transform(X[:, 0]) | |
onehotencoder = OneHotEncoder(categorical_features = [0]) | |
X = onehotencoder.fit_transform(X).toarray() | |
#Avoiding dummy variable trap | |
X = X[:, 1:] | |
# Encoding the Dependent Variable | |
labelencoder_y = LabelEncoder() | |
y = labelencoder_y.fit_transform(y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment