Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa1fca5

Browse files
jaglimaglemaitre
andauthored
DOC Ensures that RFECV passes numpydoc validation (#20452)
Co-authored-by: Guillaume Lemaitre <[email protected]>
1 parent 5a879f4 commit aa1fca5

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
"RANSACRegressor",
126126
"RBFSampler",
127127
"RFE",
128-
"RFECV",
129128
"RadiusNeighborsClassifier",
130129
"RadiusNeighborsRegressor",
131130
"RadiusNeighborsTransformer",

sklearn/feature_selection/_base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SelectorMixin(TransformerMixin, metaclass=ABCMeta):
3131

3232
def get_support(self, indices=False):
3333
"""
34-
Get a mask, or integer index, of the features selected
34+
Get a mask, or integer index, of the features selected.
3535
3636
Parameters
3737
----------
@@ -99,8 +99,7 @@ def transform(self, X):
9999
return X[:, safe_mask(X, mask)]
100100

101101
def inverse_transform(self, X):
102-
"""
103-
Reverse the transformation operation
102+
"""Reverse the transformation operation.
104103
105104
Parameters
106105
----------

sklearn/feature_selection/_rfe.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ def _estimator_type(self):
184184

185185
@property
186186
def classes_(self):
187+
"""Classes labels available when `estimator` is a classifier.
188+
189+
Returns
190+
-------
191+
ndarray of shape (n_classes,)
192+
"""
187193
return self.estimator_.classes_
188194

189195
def fit(self, X, y):
@@ -196,6 +202,11 @@ def fit(self, X, y):
196202
197203
y : array-like of shape (n_samples,)
198204
The target values.
205+
206+
Returns
207+
-------
208+
self : object
209+
Fitted estimator.
199210
"""
200211
return self._fit(X, y)
201212

@@ -407,8 +418,7 @@ def _more_tags(self):
407418

408419

409420
class RFECV(RFE):
410-
"""Feature ranking with recursive feature elimination and cross-validated
411-
selection of the best number of features.
421+
"""Recursive feature elimination with cross-validation to select the number of features.
412422
413423
See glossary entry for :term:`cross-validation estimator`.
414424
@@ -457,7 +467,7 @@ class RFECV(RFE):
457467
.. versionchanged:: 0.22
458468
``cv`` default value of None changed from 3-fold to 5-fold.
459469
460-
scoring : string, callable or None, default=None
470+
scoring : str, callable or None, default=None
461471
A string (see model evaluation documentation) or
462472
a scorer callable object / function with signature
463473
``scorer(estimator, X, y)``.
@@ -522,6 +532,10 @@ class RFECV(RFE):
522532
support_ : ndarray of shape (n_features,)
523533
The mask of selected features.
524534
535+
See Also
536+
--------
537+
RFE : Recursive feature elimination.
538+
525539
Notes
526540
-----
527541
The size of ``grid_scores_`` is equal to
@@ -530,6 +544,13 @@ class RFECV(RFE):
530544
531545
Allows NaN/Inf in the input if the underlying estimator does as well.
532546
547+
References
548+
----------
549+
550+
.. [1] Guyon, I., Weston, J., Barnhill, S., & Vapnik, V., "Gene selection
551+
for cancer classification using support vector machines",
552+
Mach. Learn., 46(1-3), 389--422, 2002.
553+
533554
Examples
534555
--------
535556
The following example shows how to retrieve the a-priori not known 5
@@ -547,17 +568,6 @@ class RFECV(RFE):
547568
False])
548569
>>> selector.ranking_
549570
array([1, 1, 1, 1, 1, 6, 4, 3, 2, 5])
550-
551-
See Also
552-
--------
553-
RFE : Recursive feature elimination.
554-
555-
References
556-
----------
557-
558-
.. [1] Guyon, I., Weston, J., Barnhill, S., & Vapnik, V., "Gene selection
559-
for cancer classification using support vector machines",
560-
Mach. Learn., 46(1-3), 389--422, 2002.
561571
"""
562572

563573
def __init__(
@@ -600,6 +610,11 @@ def fit(self, X, y, groups=None):
600610
instance (e.g., :class:`~sklearn.model_selection.GroupKFold`).
601611
602612
.. versionadded:: 0.20
613+
614+
Returns
615+
-------
616+
self : object
617+
Fitted estimator.
603618
"""
604619
tags = self._get_tags()
605620
X, y = self._validate_data(

0 commit comments

Comments
 (0)