Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 95fa18f

Browse filesBrowse files
authored
TST Fixes docstring ordering and test_docstring_parameters (#19048)
1 parent e6e543b commit 95fa18f
Copy full SHA for 95fa18f

File tree

Expand file treeCollapse file tree

13 files changed

+119
-107
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+119
-107
lines changed

‎sklearn/compose/_column_transformer.py

Copy file name to clipboardExpand all lines: sklearn/compose/_column_transformer.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,14 @@ def __init__(self, pattern=None, *, dtype_include=None,
809809
self.dtype_exclude = dtype_exclude
810810

811811
def __call__(self, df):
812+
"""Callable for column selection to be used by a
813+
:class:`ColumnTransformer`.
814+
815+
Parameters
816+
----------
817+
df : dataframe of shape (n_features, n_samples)
818+
DataFrame to select columns from.
819+
"""
812820
if not hasattr(df, 'iloc'):
813821
raise ValueError("make_column_selector can only be applied to "
814822
"pandas dataframes")

‎sklearn/covariance/_robust_covariance.py

Copy file name to clipboardExpand all lines: sklearn/covariance/_robust_covariance.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def fit(self, X, y=None):
632632
Training data, where `n_samples` is the number of samples
633633
and `n_features` is the number of features.
634634
635-
y: Ignored
635+
y : Ignored
636636
Not used, present for API consistency by convention.
637637
638638
Returns

‎sklearn/covariance/_shrunk_covariance.py

Copy file name to clipboardExpand all lines: sklearn/covariance/_shrunk_covariance.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def fit(self, X, y=None):
135135
Training data, where n_samples is the number of samples
136136
and n_features is the number of features.
137137
138-
y: Ignored
138+
y : Ignored
139139
Not used, present for API consistency by convention.
140140
141141
Returns

‎sklearn/cross_decomposition/_pls.py

Copy file name to clipboardExpand all lines: sklearn/cross_decomposition/_pls.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ class PLSRegression(_PLS):
537537
`Y = X @ coef_`.
538538
539539
n_iter_ : list of shape (n_components,)
540-
Number of iterations of the power method for each component.
540+
Number of iterations of the power method, for each
541+
component.
541542
542543
n_features_in_ : int
543544
Number of features seen during :term:`fit`.

‎sklearn/decomposition/_dict_learning.py

Copy file name to clipboardExpand all lines: sklearn/decomposition/_dict_learning.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,8 @@ def transform(self, X, y=None):
11231123
Test data to be transformed, must have the same number of
11241124
features as the data used to train the model.
11251125
1126+
y : Ignored
1127+
11261128
Returns
11271129
-------
11281130
X_new : ndarray of shape (n_samples, n_components)

‎sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py

Copy file name to clipboardExpand all lines: sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py
+16-16Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -940,14 +940,6 @@ class HistGradientBoostingRegressor(RegressorMixin, BaseHistGradientBoosting):
940940
Features with a small number of unique values may use less than
941941
``max_bins`` bins. In addition to the ``max_bins`` bins, one more bin
942942
is always reserved for missing values. Must be no larger than 255.
943-
monotonic_cst : array-like of int of shape (n_features), default=None
944-
Indicates the monotonic constraint to enforce on each feature. -1, 1
945-
and 0 respectively correspond to a negative constraint, positive
946-
constraint and no constraint. Read more in the :ref:`User Guide
947-
<monotonic_cst_gbdt>`.
948-
949-
.. versionadded:: 0.23
950-
951943
categorical_features : array-like of {bool, int} of shape (n_features) \
952944
or shape (n_categorical_features,), default=None.
953945
Indicates the categorical features.
@@ -964,6 +956,14 @@ class HistGradientBoostingRegressor(RegressorMixin, BaseHistGradientBoosting):
964956
965957
.. versionadded:: 0.24
966958
959+
monotonic_cst : array-like of int of shape (n_features), default=None
960+
Indicates the monotonic constraint to enforce on each feature. -1, 1
961+
and 0 respectively correspond to a negative constraint, positive
962+
constraint and no constraint. Read more in the :ref:`User Guide
963+
<monotonic_cst_gbdt>`.
964+
965+
.. versionadded:: 0.23
966+
967967
warm_start : bool, default=False
968968
When set to ``True``, reuse the solution of the previous call to fit
969969
and add more estimators to the ensemble. For results to be valid, the
@@ -1193,14 +1193,6 @@ class HistGradientBoostingClassifier(ClassifierMixin,
11931193
Features with a small number of unique values may use less than
11941194
``max_bins`` bins. In addition to the ``max_bins`` bins, one more bin
11951195
is always reserved for missing values. Must be no larger than 255.
1196-
monotonic_cst : array-like of int of shape (n_features), default=None
1197-
Indicates the monotonic constraint to enforce on each feature. -1, 1
1198-
and 0 respectively correspond to a negative constraint, positive
1199-
constraint and no constraint. Read more in the :ref:`User Guide
1200-
<monotonic_cst_gbdt>`.
1201-
1202-
.. versionadded:: 0.23
1203-
12041196
categorical_features : array-like of {bool, int} of shape (n_features) \
12051197
or shape (n_categorical_features,), default=None.
12061198
Indicates the categorical features.
@@ -1217,6 +1209,14 @@ class HistGradientBoostingClassifier(ClassifierMixin,
12171209
12181210
.. versionadded:: 0.24
12191211
1212+
monotonic_cst : array-like of int of shape (n_features), default=None
1213+
Indicates the monotonic constraint to enforce on each feature. -1, 1
1214+
and 0 respectively correspond to a negative constraint, positive
1215+
constraint and no constraint. Read more in the :ref:`User Guide
1216+
<monotonic_cst_gbdt>`.
1217+
1218+
.. versionadded:: 0.23
1219+
12201220
warm_start : bool, default=False
12211221
When set to ``True``, reuse the solution of the previous call to fit
12221222
and add more estimators to the ensemble. For results to be valid, the

‎sklearn/feature_selection/_sequential.py

Copy file name to clipboardExpand all lines: sklearn/feature_selection/_sequential.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SequentialFeatureSelector(SelectorMixin, MetaEstimatorMixin,
3636
to select. If float between 0 and 1, it is the fraction of features to
3737
select.
3838
39-
direction: {'forward', 'backward'}, default='forward'
39+
direction : {'forward', 'backward'}, default='forward'
4040
Whether to perform forward selection or backward selection.
4141
4242
scoring : str, callable, list/tuple or dict, default=None

‎sklearn/linear_model/_glm/glm.py

Copy file name to clipboardExpand all lines: sklearn/linear_model/_glm/glm.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,10 @@ class TweedieRegressor(GeneralizedLinearRegressor):
593593
GLMs. In this case, the design matrix `X` must have full column rank
594594
(no collinearities).
595595
596+
fit_intercept : bool, default=True
597+
Specifies if a constant (a.k.a. bias or intercept) should be
598+
added to the linear predictor (X @ coef + intercept).
599+
596600
link : {'auto', 'identity', 'log'}, default='auto'
597601
The link function of the GLM, i.e. mapping from linear predictor
598602
`X @ coeff + intercept` to prediction `y_pred`. Option 'auto' sets
@@ -601,10 +605,6 @@ class TweedieRegressor(GeneralizedLinearRegressor):
601605
- 'identity' for Normal distribution
602606
- 'log' for Poisson, Gamma and Inverse Gaussian distributions
603607
604-
fit_intercept : bool, default=True
605-
Specifies if a constant (a.k.a. bias or intercept) should be
606-
added to the linear predictor (X @ coef + intercept).
607-
608608
max_iter : int, default=100
609609
The maximal number of iterations for the solver.
610610

‎sklearn/metrics/_plot/det_curve.py

Copy file name to clipboardExpand all lines: sklearn/metrics/_plot/det_curve.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class DetCurveDisplay:
2222
fpr : ndarray
2323
False positive rate.
2424
25-
tpr : ndarray
26-
True positive rate.
25+
fnr : ndarray
26+
False negative rate.
2727
2828
estimator_name : str, default=None
2929
Name of estimator. If None, the estimator name is not shown.

‎sklearn/model_selection/_search.py

Copy file name to clipboardExpand all lines: sklearn/model_selection/_search.py
+72-72Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,42 +1024,6 @@ class GridSearchCV(BaseSearchCV):
10241024
.. versionchanged:: v0.20
10251025
`n_jobs` default changed from 1 to None
10261026
1027-
pre_dispatch : int, or str, default=n_jobs
1028-
Controls the number of jobs that get dispatched during parallel
1029-
execution. Reducing this number can be useful to avoid an
1030-
explosion of memory consumption when more jobs get dispatched
1031-
than CPUs can process. This parameter can be:
1032-
1033-
- None, in which case all the jobs are immediately
1034-
created and spawned. Use this for lightweight and
1035-
fast-running jobs, to avoid delays due to on-demand
1036-
spawning of the jobs
1037-
1038-
- An int, giving the exact number of total jobs that are
1039-
spawned
1040-
1041-
- A str, giving an expression as a function of n_jobs,
1042-
as in '2*n_jobs'
1043-
1044-
cv : int, cross-validation generator or an iterable, default=None
1045-
Determines the cross-validation splitting strategy.
1046-
Possible inputs for cv are:
1047-
1048-
- None, to use the default 5-fold cross validation,
1049-
- integer, to specify the number of folds in a `(Stratified)KFold`,
1050-
- :term:`CV splitter`,
1051-
- An iterable yielding (train, test) splits as arrays of indices.
1052-
1053-
For integer/None inputs, if the estimator is a classifier and ``y`` is
1054-
either binary or multiclass, :class:`StratifiedKFold` is used. In all
1055-
other cases, :class:`KFold` is used.
1056-
1057-
Refer :ref:`User Guide <cross_validation>` for the various
1058-
cross-validation strategies that can be used here.
1059-
1060-
.. versionchanged:: 0.22
1061-
``cv`` default value if None changed from 3-fold to 5-fold.
1062-
10631027
refit : bool, str, or callable, default=True
10641028
Refit an estimator using the best found parameters on the whole
10651029
dataset.
@@ -1090,6 +1054,25 @@ class GridSearchCV(BaseSearchCV):
10901054
.. versionchanged:: 0.20
10911055
Support for callable added.
10921056
1057+
cv : int, cross-validation generator or an iterable, default=None
1058+
Determines the cross-validation splitting strategy.
1059+
Possible inputs for cv are:
1060+
1061+
- None, to use the default 5-fold cross validation,
1062+
- integer, to specify the number of folds in a `(Stratified)KFold`,
1063+
- :term:`CV splitter`,
1064+
- An iterable yielding (train, test) splits as arrays of indices.
1065+
1066+
For integer/None inputs, if the estimator is a classifier and ``y`` is
1067+
either binary or multiclass, :class:`StratifiedKFold` is used. In all
1068+
other cases, :class:`KFold` is used.
1069+
1070+
Refer :ref:`User Guide <cross_validation>` for the various
1071+
cross-validation strategies that can be used here.
1072+
1073+
.. versionchanged:: 0.22
1074+
``cv`` default value if None changed from 3-fold to 5-fold.
1075+
10931076
verbose : int
10941077
Controls the verbosity: the higher, the more messages.
10951078
@@ -1099,6 +1082,23 @@ class GridSearchCV(BaseSearchCV):
10991082
- >3 : the fold and candidate parameter indexes are also displayed
11001083
together with the starting time of the computation.
11011084
1085+
pre_dispatch : int, or str, default=n_jobs
1086+
Controls the number of jobs that get dispatched during parallel
1087+
execution. Reducing this number can be useful to avoid an
1088+
explosion of memory consumption when more jobs get dispatched
1089+
than CPUs can process. This parameter can be:
1090+
1091+
- None, in which case all the jobs are immediately
1092+
created and spawned. Use this for lightweight and
1093+
fast-running jobs, to avoid delays due to on-demand
1094+
spawning of the jobs
1095+
1096+
- An int, giving the exact number of total jobs that are
1097+
spawned
1098+
1099+
- A str, giving an expression as a function of n_jobs,
1100+
as in '2*n_jobs'
1101+
11021102
error_score : 'raise' or numeric, default=np.nan
11031103
Value to assign to the score if an error occurs in estimator fitting.
11041104
If set to 'raise', the error is raised. If a numeric value is given,
@@ -1366,42 +1366,6 @@ class RandomizedSearchCV(BaseSearchCV):
13661366
.. versionchanged:: v0.20
13671367
`n_jobs` default changed from 1 to None
13681368
1369-
pre_dispatch : int, or str, default=None
1370-
Controls the number of jobs that get dispatched during parallel
1371-
execution. Reducing this number can be useful to avoid an
1372-
explosion of memory consumption when more jobs get dispatched
1373-
than CPUs can process. This parameter can be:
1374-
1375-
- None, in which case all the jobs are immediately
1376-
created and spawned. Use this for lightweight and
1377-
fast-running jobs, to avoid delays due to on-demand
1378-
spawning of the jobs
1379-
1380-
- An int, giving the exact number of total jobs that are
1381-
spawned
1382-
1383-
- A str, giving an expression as a function of n_jobs,
1384-
as in '2*n_jobs'
1385-
1386-
cv : int, cross-validation generator or an iterable, default=None
1387-
Determines the cross-validation splitting strategy.
1388-
Possible inputs for cv are:
1389-
1390-
- None, to use the default 5-fold cross validation,
1391-
- integer, to specify the number of folds in a `(Stratified)KFold`,
1392-
- :term:`CV splitter`,
1393-
- An iterable yielding (train, test) splits as arrays of indices.
1394-
1395-
For integer/None inputs, if the estimator is a classifier and ``y`` is
1396-
either binary or multiclass, :class:`StratifiedKFold` is used. In all
1397-
other cases, :class:`KFold` is used.
1398-
1399-
Refer :ref:`User Guide <cross_validation>` for the various
1400-
cross-validation strategies that can be used here.
1401-
1402-
.. versionchanged:: 0.22
1403-
``cv`` default value if None changed from 3-fold to 5-fold.
1404-
14051369
refit : bool, str, or callable, default=True
14061370
Refit an estimator using the best found parameters on the whole
14071371
dataset.
@@ -1432,9 +1396,45 @@ class RandomizedSearchCV(BaseSearchCV):
14321396
.. versionchanged:: 0.20
14331397
Support for callable added.
14341398
1399+
cv : int, cross-validation generator or an iterable, default=None
1400+
Determines the cross-validation splitting strategy.
1401+
Possible inputs for cv are:
1402+
1403+
- None, to use the default 5-fold cross validation,
1404+
- integer, to specify the number of folds in a `(Stratified)KFold`,
1405+
- :term:`CV splitter`,
1406+
- An iterable yielding (train, test) splits as arrays of indices.
1407+
1408+
For integer/None inputs, if the estimator is a classifier and ``y`` is
1409+
either binary or multiclass, :class:`StratifiedKFold` is used. In all
1410+
other cases, :class:`KFold` is used.
1411+
1412+
Refer :ref:`User Guide <cross_validation>` for the various
1413+
cross-validation strategies that can be used here.
1414+
1415+
.. versionchanged:: 0.22
1416+
``cv`` default value if None changed from 3-fold to 5-fold.
1417+
14351418
verbose : int
14361419
Controls the verbosity: the higher, the more messages.
14371420
1421+
pre_dispatch : int, or str, default=None
1422+
Controls the number of jobs that get dispatched during parallel
1423+
execution. Reducing this number can be useful to avoid an
1424+
explosion of memory consumption when more jobs get dispatched
1425+
than CPUs can process. This parameter can be:
1426+
1427+
- None, in which case all the jobs are immediately
1428+
created and spawned. Use this for lightweight and
1429+
fast-running jobs, to avoid delays due to on-demand
1430+
spawning of the jobs
1431+
1432+
- An int, giving the exact number of total jobs that are
1433+
spawned
1434+
1435+
- A str, giving an expression as a function of n_jobs,
1436+
as in '2*n_jobs'
1437+
14381438
random_state : int, RandomState instance or None, default=None
14391439
Pseudo random number generator state used for random uniform sampling
14401440
from lists of possible values instead of scipy.stats distributions.

‎sklearn/preprocessing/_data.py

Copy file name to clipboardExpand all lines: sklearn/preprocessing/_data.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class MinMaxScaler(TransformerMixin, BaseEstimator):
244244
Set to False to perform inplace row normalization and avoid a
245245
copy (if the input is already a numpy array).
246246
247-
clip: bool, default=False
247+
clip : bool, default=False
248248
Set to True to clip transformed values of held-out data to
249249
provided `feature range`.
250250

‎sklearn/semi_supervised/_self_training.py

Copy file name to clipboardExpand all lines: sklearn/semi_supervised/_self_training.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class SelfTrainingClassifier(MetaEstimatorMixin, BaseEstimator):
4141
Invoking the ``fit`` method will fit a clone of the passed estimator,
4242
which will be stored in the ``base_estimator_`` attribute.
4343
44+
threshold : float, default=0.75
45+
The decision threshold for use with `criterion='threshold'`.
46+
Should be in [0, 1). When using the 'threshold' criterion, a
47+
:ref:`well calibrated classifier <calibration>` should be used.
48+
4449
criterion : {'threshold', 'k_best'}, default='threshold'
4550
The selection criterion used to select which labels to add to the
4651
training set. If 'threshold', pseudo-labels with prediction
@@ -49,11 +54,6 @@ class SelfTrainingClassifier(MetaEstimatorMixin, BaseEstimator):
4954
added to the dataset. When using the 'threshold' criterion, a
5055
:ref:`well calibrated classifier <calibration>` should be used.
5156
52-
threshold : float, default=0.75
53-
The decision threshold for use with `criterion='threshold'`.
54-
Should be in [0, 1). When using the 'threshold' criterion, a
55-
:ref:`well calibrated classifier <calibration>` should be used.
56-
5757
k_best : int, default=10
5858
The amount of samples to add in each iteration. Only used when
5959
`criterion` is k_best'.
@@ -64,7 +64,7 @@ class SelfTrainingClassifier(MetaEstimatorMixin, BaseEstimator):
6464
until no new pseudo-labels are added, or all unlabeled samples have
6565
been labeled.
6666
67-
verbose: bool, default=False
67+
verbose : bool, default=False
6868
Enable verbose output.
6969
7070
Attributes

‎sklearn/tests/test_docstring_parameters.py

Copy file name to clipboardExpand all lines: sklearn/tests/test_docstring_parameters.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ def test_docstring_parameters():
8383
with warnings.catch_warnings(record=True):
8484
module = importlib.import_module(name)
8585
classes = inspect.getmembers(module, inspect.isclass)
86-
# Exclude imported classes
87-
classes = [cls for cls in classes if cls[1].__module__ == name]
86+
# Exclude non-scikit-learn classes
87+
classes = [cls for cls in classes
88+
if cls[1].__module__.startswith('sklearn')]
8889
for cname, cls in classes:
8990
this_incorrect = []
9091
if cname in _DOCSTRING_IGNORES or cname.startswith('_'):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.