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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/release_notes.rst
Expand Up @@ -4,6 +4,7 @@ Release Notes
* Enhancements
* Fixes
* Fixed github workflows for featuretools and woodwork to test their main branch against evalml. :pr:`3517`
* Supress warnings in ``TargetEncoder`` raised by a coming change to default parameters :pr:`3540`
* Changes
* Transitioned to use pyproject.toml and setup.cfg away from setup.py :pr:`3494`, :pr:`3536`
* Documentation Changes
Expand Down
@@ -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
Contributor

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