Skip to content

Commit

Permalink
Changed the target imputer to just look for all nulls in the target a…
Browse files Browse the repository at this point in the history
…nd raise.
  • Loading branch information
chukarsten committed Aug 10, 2021
1 parent b4f1ae0 commit 004f752
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,12 @@ def fit(self, X, y):
Returns:
self
"""
from woodwork.logical_types import Unknown

if y is None:
return self
y = infer_feature_types(y)
if isinstance(y.ww.logical_type, Unknown):
raise TypeError("Provided target full of pd.NA.")
if all(y.isnull()):
raise TypeError("Provided target full of nulls.")
y = y.to_frame()
# should y be an un-inited dataframe?

# Convert all bool dtypes to category for fitting
if (y.dtypes == bool).all():
Expand Down
4 changes: 2 additions & 2 deletions evalml/tests/component_tests/test_target_imputer.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ def test_target_imputer_fit_transform_all_nan_empty(y):

imputer = TargetImputer()

with pytest.raises(TypeError, match="Provided target full of pd.NA."):
with pytest.raises(TypeError, match="Provided target full of nulls."):
imputer.fit(None, y)

imputer = TargetImputer()
with pytest.raises(TypeError, match="Provided target full of pd.NA."):
with pytest.raises(TypeError, match="Provided target full of nulls."):
imputer.fit_transform(None, y)


Expand Down
2 changes: 1 addition & 1 deletion evalml/tests/pipeline_tests/test_pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_make_pipeline(
)
imputer = (
[]
if (column_names == ["dates"] and input_type == "ww")
if (column_names in [["dates"], ["all_null"]] and input_type == "ww")
or ((column_names in [["text"], ["dates"]]) and input_type == "pd")
else [Imputer]
)
Expand Down

0 comments on commit 004f752

Please sign in to comment.