Skip to content

Instantly share code, notes, and snippets.

@risenW
Created December 2, 2019 15:02
Show Gist options
  • Save risenW/6b10d33001a265ab33e4df286fa175e5 to your computer and use it in GitHub Desktop.
Save risenW/6b10d33001a265ab33e4df286fa175e5 to your computer and use it in GitHub Desktop.
import category_encoders as ce
# drop target column
target = train['Claim'].values
train.drop(columns='Claim', axis=1, inplace=True)
enc = ce.OrdinalEncoder(cols=['Geo_Code'])
enc.fit(train)
train_enc = enc.transform(train)
test_enc = enc.transform(test)
#one-hot-encode the rest categorical features
hot_enc = ce.OneHotEncoder()
hot_enc.fit(train_enc)
train_enc = hot_enc.transform(train_enc)
test_enc = hot_enc.transform(test_enc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment