Skip to content

Instantly share code, notes, and snippets.

@Younes-Charfaoui
Created June 28, 2020 19:19
Show Gist options
  • Select an option

  • Save Younes-Charfaoui/ce9e1bc8e64fe7625eb792cabd331a7a to your computer and use it in GitHub Desktop.

Select an option

Save Younes-Charfaoui/ce9e1bc8e64fe7625eb792cabd331a7a to your computer and use it in GitHub Desktop.
# import the pandas and James Stein encoders libraries.
import pandas as pd
from category_encoders import JamesSteinEncoder
# get you data.
data = pd.read_csv("yourData.csv")
# create the encoder.
encoder = JamesSteinEncoder(return_df=True)
# fit and transform the data.
new_x_train = encoder.fit_transform(x_train, y_train)
new_x_test = encoder.transform(x_test, y_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment