Created
May 18, 2023 19:14
-
-
Save dleybz/2b9620835d63e1b6e4a88ede6ce214d1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from category_encoders import TargetEncoder | |
| def encode_categorical(df): | |
| te = TargetEncoder() | |
| cols = df.select_dtypes('object').columns | |
| for col in cols: | |
| df.loc[:, col] = te.fit_transform(X=df[col], y=df['FraudFound']) | |
| return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment