8000 DOC Ensures that SelectFromModel passes numpydoc validation (#20988) · adrinjalali/scikit-learn@065bca8 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit 065bca8

Browse files
jmloyolaglemaitre
authored andcommitted
DOC Ensures that SelectFromModel passes numpydoc validation (scikit-learn#20988)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent b086529 commit 065bca8

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"RobustScaler",
6161
"SGDOneClassSVM",
6262
"SGDRegressor",
63-
"SelectFromModel",
6463
"SelfTrainingClassifier",
6564
"SequentialFeatureSelector",
6665
"SimpleImputer",

sklearn/feature_selection/_from_model.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SelectFromModel(MetaEstimatorMixin, SelectorMixin, BaseEstimator):
7676
``feature_importances_`` or ``coef_`` attribute after fitting.
7777
Otherwise, the ``importance_getter`` parameter should be used.
7878
79-
threshold : string or float, default=None
79+
threshold : str or float, default=None
8080
The threshold value to use for feature selection. Features whose
8181
importance is greater or equal are kept while the others are
8282
discarded. If "median" (resp. "mean"), then the ``threshold`` value is
@@ -144,6 +144,14 @@ class SelectFromModel(MetaEstimatorMixin, SelectorMixin, BaseEstimator):
144144
threshold_ : float
145145
The threshold value used for feature selection.
146146
147+
See Also
148+
--------
149+
RFE : Recursive feature elimination based on importance weights.
150+
RFECV : Recursive feature elimination with built-in cross-validated
151+
selection of the best number of features.
152+
SequentialFeatureSelector : Sequential cross-validation based feature
153+
selection. Does not rely on importance weights.
154+
147155
Notes
148156
-----
149157
Allows NaN/Inf in the input if the underlying estimator does as well.
@@ -169,14 +177,6 @@ class SelectFromModel(MetaEstimatorMixin, SelectorMixin, BaseEstimator):
169177
[-0.02],
170178
[-0.48],
171179
[ 1.48]])
172-
173-
See Also
174-
--------
175-
RFE : Recursive feature elimination based on importance weights.
176-
RFECV : Recursive feature elimination with built-in cross-validated
177-
selection of the best number of features.
178-
SequentialFeatureSelector : Sequential cross-validation based feature
179-
selection. Does not rely on importance weights.
180180
"""
181181

182182
def __init__(
@@ -238,11 +238,13 @@ def fit(self, X, y=None, **fit_params):
238238
The target values (integers that correspond to classes in
239239
classification, real numbers in regression).
240240
241-
**fit_params : Other estimator specific parameters
241+
**fit_params : dict
242+
Other estimator specific parameters.
242243
243244
Returns
244245
-------
245246
self : object
247+
Fitted estimator.
246248
"""
247249
if self.max_features is not None:
248250
if not isinstance(self.max_features, numbers.Integral):
@@ -269,6 +271,7 @@ def fit(self, X, y=None, **fit_params):
269271

270272
@property
271273
def threshold_(self):
274+
"""Threshold value used for feature selection."""
272275
scores = _get_feature_importances(
273276
estimator=self.estimator_,
274277
getter=self.importance_getter,
@@ -290,11 +293,13 @@ def partial_fit(self, X, y=None, **fit_params):
290293
The target values (integers that correspond to classes in
291294
classification, real numbers in regression).
292295
293-
**fit_params : Other estimator specific parameters
296+
**fit_params : dict
297+
Other estimator specific parameters.
294298
295299
Returns
296300
-------
297301
self : object
302+
Fitted estimator.
298303
"""
299304
if self.prefit:
300305
raise NotFittedError("Since 'prefit=True', call transform directly")
@@ -305,6 +310,7 @@ def partial_fit(self, X, y=None, **fit_params):
305310

306311
@property
307312
def n_features_in_(self):
313+
"""Number of features seen during `fit`."""
308314
# For consistency with other estimators we raise a AttributeError so
309315
# that hasattr() fails if the estimator isn't fitted.
310316
try:

0 commit comments

Comments
 (0)
0