Skip to content

Commit 2ddf0ce

Browse files
Arthur DouillardNelleV
authored andcommitted
[MRG + 1] rfecv: verbosity: Set verbose threshold low bound from 2 to 1 (scikit-learn#7644)
* rfecv: verbosity: Set verbose threshold low bound from 2 to 1 * rfecv: verbosity: Add test checking verbose=1 produce output * rfecv: verbosity: Change docstring to comment * rfecv: verbosity: Fix test, missing seek
1 parent aa57569 commit 2ddf0ce

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

sklearn/feature_selection/rfe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def fit(self, X, y):
406406

407407
rfe = RFE(estimator=self.estimator,
408408
n_features_to_select=n_features_to_select,
409-
step=self.step, verbose=self.verbose - 1)
409+
step=self.step, verbose=self.verbose)
410410

411411
# Determine the number of subsets of features by fitting across
412412
# the train folds and choosing the "features_to_select" parameter

sklearn/feature_selection/tests/test_rfe.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,25 @@ def test_rfecv_mockclassifier():
203203
assert_equal(len(rfecv.ranking_), X.shape[1])
204204

205205

206+
def test_rfecv_verbose_output():
207+
# Check verbose=1 is producing an output.
208+
from sklearn.externals.six.moves import cStringIO as StringIO
209+
import sys
210+
sys.stdout = StringIO()
211+
212+
generator = check_random_state(0)
213+
iris = load_iris()
214+
X = np.c_[iris.data, generator.normal(size=(len(iris.data), 6))]
215+
y = list(iris.target)
216+
217+
rfecv = RFECV(estimator=SVC(kernel="linear"), step=1, cv=5, verbose=1)
218+
rfecv.fit(X, y)
219+
220+
verbose_output = sys.stdout
221+
verbose_output.seek(0)
222+
assert_greater(len(verbose_output.readline()), 0)
223+
224+
206225
def test_rfe_estimator_tags():
207226
rfe = RFE(SVC(kernel='linear'))
208227
assert_equal(rfe._estimator_type, "classifier")

0 commit comments

Comments
 (0)