Skip to content
Snippets Groups Projects
Commit 102620f8 authored by Joel Nothman's avatar Joel Nothman Committed by Olivier Grisel
Browse files

[MRG] FIX bug in nested set_params usage (#9999)

parent 7f19dbeb
No related branches found
No related tags found
No related merge requests found
...@@ -122,6 +122,10 @@ Decomposition, manifold learning and clustering ...@@ -122,6 +122,10 @@ Decomposition, manifold learning and clustering
with large datasets when ``n_components='mle'`` on Python 3 versions. with large datasets when ``n_components='mle'`` on Python 3 versions.
:issue:`9886` by :user:`Hanmin Qin <qinhanmin2014>`. :issue:`9886` by :user:`Hanmin Qin <qinhanmin2014>`.
- Fixed a bug when setting parameters on meta-estimator, involving both a
wrapped estimator and its parameter. :issue:`9999` by :user:`Marcus Voss
<marcus-voss>` and `Joel Nothman`_.
Metrics Metrics
- Fixed a bug due to floating point error in :func:`metrics.roc_auc_score` with - Fixed a bug due to floating point error in :func:`metrics.roc_auc_score` with
......
...@@ -263,6 +263,7 @@ class BaseEstimator(object): ...@@ -263,6 +263,7 @@ class BaseEstimator(object):
nested_params[key][sub_key] = value nested_params[key][sub_key] = value
else: else:
setattr(self, key, value) setattr(self, key, value)
valid_params[key] = value
for key, sub_params in nested_params.items(): for key, sub_params in nested_params.items():
valid_params[key].set_params(**sub_params) valid_params[key].set_params(**sub_params)
......
...@@ -246,6 +246,14 @@ def test_set_params_passes_all_parameters(): ...@@ -246,6 +246,14 @@ def test_set_params_passes_all_parameters():
estimator__min_samples_leaf=2) estimator__min_samples_leaf=2)
def test_set_params_updates_valid_params():
# Check that set_params tries to set SVC().C, not
# DecisionTreeClassifier().C
gscv = GridSearchCV(DecisionTreeClassifier(), {})
gscv.set_params(estimator=SVC(), estimator__C=42.0)
assert gscv.estimator.C == 42.0
def test_score_sample_weight(): def test_score_sample_weight():
rng = np.random.RandomState(0) rng = np.random.RandomState(0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment