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

Fix CategoricalEncoder error message when thirdparty library is missing #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
9 changes: 3 additions & 6 deletions aikit/transformers/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ class CategoricalEncoder(ModelWrapper):
Parameters
----------

columns_to_encode : None or list of str
the columns to encode (if None will guess)

encoding_type : str, default = 'dummy'
the type of encoding, possible choices :
* dummy
Expand All @@ -380,7 +377,7 @@ class CategoricalEncoder(ModelWrapper):
the size of hashing when using encoding_type == 'hashing'

columns_to_use : list of str or None
the columns to use for that encoder
the columns to use for that encoder (if None will guess)

regex_match : boolean
if True will use regex to match columns
Expand Down Expand Up @@ -413,7 +410,7 @@ def __init__(
):

if category_encoders is None:
raise ValueError("You need to install 'categorical-encoder' to use this wrapper")
raise ValueError("'category_encoders' not found and required to use this wrapper, run 'pip install category_encoders'")

self.columns_to_use = columns_to_use
self.encoding_type = encoding_type
Expand Down Expand Up @@ -442,7 +439,7 @@ def __init__(

def _get_model(self, X, y=None):

params = dict(cols=self.columns_to_encode, return_df=self.desired_output_type == DataTypes.DataFrame)
params = dict(cols=self.columns_to_use, return_df=self.desired_output_type == DataTypes.DataFrame)

if self.encoding_type == "dummy":
return category_encoders.OneHotEncoder(use_cat_names=True, **params)
Expand Down