Skip to content

Commit

Permalink
Remove SimpleImputer DeprecationWarning (#1018)
Browse files Browse the repository at this point in the history
* init remove simpleimputer

* revert and remove warning

* fix

* release and lint

* delete for codecov

* revert and add tests
  • Loading branch information
angela97lin committed Aug 5, 2020
1 parent 6749c3c commit e63c32f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions docs/source/release_notes.rst
Expand Up @@ -5,6 +5,7 @@ Release Notes
* Enhancements
* Fixes
* Changes
* Removed DeprecationWarning for SimpleImputer :pr:`1018`
* Documentation Changes
* Testing Changes

Expand Down
@@ -1,5 +1,3 @@
import warnings

import pandas as pd
from sklearn.impute import SimpleImputer as SkImputer

Expand All @@ -20,8 +18,6 @@ def __init__(self, impute_strategy="most_frequent", fill_value=None, random_stat
fill_value (string): When impute_strategy == "constant", fill_value is used to replace missing data.
Defaults to 0 when imputing numerical data and "missing_value" for strings or object data types.
"""
warnings.warn("SimpleImputer is deprecated in v0.12.0 and will be removed in 0.13.0 in favor of Imputer", DeprecationWarning)

parameters = {"impute_strategy": impute_strategy,
"fill_value": fill_value}
parameters.update(kwargs)
Expand Down
19 changes: 19 additions & 0 deletions evalml/tests/component_tests/test_feature_selectors.py
@@ -1,5 +1,9 @@
import pandas as pd
import pytest

from evalml.pipelines.components import (
ComponentBase,
FeatureSelector,
RFClassifierSelectFromModel,
RFRegressorSelectFromModel
)
Expand Down Expand Up @@ -38,3 +42,18 @@ def test_component_fit(X_y_binary, X_y_multi, X_y_regression):
assert isinstance(rf_classifier.fit(X_binary, y_binary), ComponentBase)
assert isinstance(rf_classifier.fit(X_multi, y_multi), ComponentBase)
assert isinstance(rf_regressor.fit(X_reg, y_reg), ComponentBase)


def test_feature_selector_missing_component_obj():
class MockFeatureSelector(FeatureSelector):
name = "Mock Feature Selector"

def fit(self, X, y):
pass

mock_feature_selector = MockFeatureSelector()
mock_feature_selector.fit(pd.DataFrame(), pd.Series())
with pytest.raises(RuntimeError, match="Transformer requires a transform method or a component_obj that implements transform"):
mock_feature_selector.transform(pd.DataFrame())
with pytest.raises(RuntimeError, match="Transformer requires a fit_transform method or a component_obj that implements fit_transform"):
mock_feature_selector.fit_transform(pd.DataFrame())
11 changes: 0 additions & 11 deletions evalml/tests/component_tests/test_simple_imputer.py
@@ -1,5 +1,3 @@
import warnings

import numpy as np
import pandas as pd
import pytest
Expand Down Expand Up @@ -151,12 +149,3 @@ def test_numpy_input():
np.testing.assert_almost_equal(X, np.array([[np.nan, 0, 1, np.nan],
[np.nan, 2, 3, 2],
[np.nan, 2, 3, 0]]))


def test_simple_imputer_deprecation_warning():
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
SimpleImputer(impute_strategy='mean')
assert len(w) == 1
assert issubclass(w[-1].category, DeprecationWarning)
assert "deprecated" in str(w[-1].message)

0 comments on commit e63c32f

Please sign in to comment.