Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surpress warnings in target encoder #3540

Merged
merged 2 commits into from
Jun 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""A transformer that encodes categorical features into target encodings."""
import warnings

import pandas as pd

from ..transformer import Transformer
Expand Down Expand Up @@ -31,7 +33,7 @@ class TargetEncoder(Transformer, metaclass=OneHotEncoderMeta):
def __init__(
self,
cols=None,
smoothing=1.0,
smoothing=1,
handle_unknown="value",
handle_missing="value",
random_seed=0,
Expand Down Expand Up @@ -65,9 +67,14 @@ def __init__(
"category_encoders",
error_msg="category_encoders not installed. Please install using `pip install category_encoders`",
)
# Supress warnings for now due to problems discussion here:
# https://github.com/scikit-learn-contrib/category_encoders/issues/327
with warnings.catch_warnings():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also change the default value of smoothing and add min_samples_leaf parameter but there is still some discussion as to what the new defaults should be so figured it was better to suppress the warnings

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed!

warnings.simplefilter("ignore")
encoder = category_encode.target_encoder.TargetEncoder(**parameters)
super().__init__(
parameters=parameters,
component_obj=category_encode.target_encoder.TargetEncoder(**parameters),
component_obj=encoder,
random_seed=random_seed,
)

Expand Down