Skip to content

Commit c247141

Browse files
committed
Merge pull request scikit-learn#4462 from xuewei4d/deprecate_estimator_params_docstring
[MRG] DOC & COSMIT deprecate estimator_params in RFE and RFE_CV in docstring
2 parents aa49239 + 17ee7dd commit c247141

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

sklearn/feature_selection/rfe.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class RFE(BaseEstimator, MetaEstimatorMixin, SelectorMixin):
5555
5656
estimator_params : dict
5757
Parameters for the external estimator.
58-
Useful for doing grid searches when an `RFE` object is passed as an
59-
argument to, e.g., a `sklearn.grid_search.GridSearchCV` object.
58+
This attribute is deprecated as of version 0.16 and will be removed in
59+
0.18. Use estimator initialisation or set_params method instead.
6060
6161
verbose : int, default=0
6262
Controls verbosity of output.
@@ -138,11 +138,11 @@ def fit(self, X, y):
138138
raise ValueError("Step must be >0")
139139

140140
if self.estimator_params is not None:
141-
warnings.warn("The parameter 'estimator_params' is deprecated as of version 0.16 "
142-
"and will be removed in 0.18. The parameter is no longer "
143-
"necessary because the value is set via the estimator initialisation "
144-
"or set_params function."
145-
, DeprecationWarning)
141+
warnings.warn("The parameter 'estimator_params' is deprecated as "
142+
"of version 0.16 and will be removed in 0.18. The "
143+
"parameter is no longer necessary because the value "
144+
"is set via the estimator initialisation or "
145+
"set_params method.", DeprecationWarning)
146146

147147
support_ = np.ones(n_features, dtype=np.bool)
148148
ranking_ = np.ones(n_features, dtype=np.int)
@@ -266,8 +266,8 @@ class RFECV(RFE, MetaEstimatorMixin):
266266
267267
estimator_params : dict
268268
Parameters for the external estimator.
269-
Useful for doing grid searches when an `RFE` object is passed as an
270-
argument to, e.g., a `sklearn.grid_search.GridSearchCV` object.
269+
This attribute is deprecated as of version 0.16 and will be removed in
270+
0.18. Use estimator initialisation or set_params method instead.
271271
272272
verbose : int, default=0
273273
Controls verbosity of output.
@@ -350,11 +350,11 @@ def fit(self, X, y):
350350
"""
351351
X, y = check_X_y(X, y, "csr")
352352
if self.estimator_params is not None:
353-
warnings.warn("The parameter 'estimator_params' is deprecated as of version 0.16 "
354-
"and will be removed in 0.18. The parameter is no longer "
355-
"necessary because the value is set via the estimator initialisation "
356-
"or set_params function."
357-
, DeprecationWarning)
353+
warnings.warn("The parameter 'estimator_params' is deprecated as "
354+
"of version 0.16 and will be removed in 0.18. "
355+
"The parameter is no longer necessary because the "
356+
"value is set via the estimator initialisation or "
357+
"set_params method.", DeprecationWarning)
358358
# Initialization
359359
rfe = RFE(estimator=self.estimator, n_features_to_select=1,
360360
step=self.step, estimator_params=self.estimator_params,

sklearn/feature_selection/tests/test_rfe.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ def test_rfe_set_params():
7070

7171

7272
def test_rfe_deprecation_estimator_params():
73-
deprecation_message = ("The parameter 'estimator_params' is deprecated as of version 0.16 "
74-
"and will be removed in 0.18. The parameter is no longer "
75-
"necessary because the value is set via the estimator initialisation "
76-
"or set_params function.")
73+
deprecation_message = ("The parameter 'estimator_params' is deprecated as "
74+
"of version 0.16 and will be removed in 0.18. The "
75+
"parameter is no longer necessary because the "
76+
"value is set via the estimator initialisation or "
77+
"set_params method.")
7778
generator = check_random_state(0)
7879
iris = load_iris()
7980
X = np.c_[iris.data, generator.normal(size=(len(iris.data), 6))]

0 commit comments

Comments
 (0)