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

Skip to content

Commit 8d62171

Browse files
reshamasogrisel
andauthored
DOC adding valid intervals for SGDClassifier class parameters (#22115)
Co-authored-by: Olivier Grisel <[email protected]>
1 parent fdf5533 commit 8d62171

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

doc/glossary.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,7 @@ functions or non-estimator constructors.
16041604
number of different distinct random seeds. Popular integer
16051605
random seeds are 0 and `42
16061606
<https://en.wikipedia.org/wiki/Answer_to_the_Ultimate_Question_of_Life%2C_the_Universe%2C_and_Everything>`_.
1607+
Integer values must be in the range `[0, 2**32 - 1]`.
16071608

16081609
A :class:`numpy.random.RandomState` instance
16091610
Use the provided random state, only affecting other users

sklearn/linear_model/_stochastic_gradient.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -955,11 +955,13 @@ class SGDClassifier(BaseSGDClassifier):
955955
value, the stronger the regularization.
956956
Also used to compute the learning rate when set to `learning_rate` is
957957
set to 'optimal'.
958+
Values must be in the range `[0.0, inf)`.
958959
959960
l1_ratio : float, default=0.15
960961
The Elastic Net mixing parameter, with 0 <= l1_ratio <= 1.
961962
l1_ratio=0 corresponds to L2 penalty, l1_ratio=1 to L1.
962963
Only used if `penalty` is 'elasticnet'.
964+
Values must be in the range `[0.0, 1.0]`.
963965
964966
fit_intercept : bool, default=True
965967
Whether the intercept should be estimated or not. If False, the
@@ -969,6 +971,7 @@ class SGDClassifier(BaseSGDClassifier):
969971
The maximum number of passes over the training data (aka epochs).
970972
It only impacts the behavior in the ``fit`` method, and not the
971973
:meth:`partial_fit` method.
974+
Values must be in the range `[1, inf)`.
972975
973976
.. versionadded:: 0.19
974977
@@ -978,6 +981,7 @@ class SGDClassifier(BaseSGDClassifier):
978981
epochs.
979982
Convergence is checked against the training loss or the
980983
validation loss depending on the `early_stopping` parameter.
984+
Values must be in the range `[0.0, inf)`.
981985
982986
.. versionadded:: 0.19
983987
@@ -986,6 +990,7 @@ class SGDClassifier(BaseSGDClassifier):
986990
987991
verbose : int, default=0
988992
The verbosity level.
993+
Values must be in the range `[0, inf)`.
989994
990995
epsilon : float, default=0.1
991996
Epsilon in the epsilon-insensitive loss functions; only if `loss` is
@@ -994,6 +999,7 @@ class SGDClassifier(BaseSGDClassifier):
994999
important to get the prediction exactly right.
9951000
For epsilon-insensitive, any differences between the current prediction
9961001
and the correct label are ignored if they are less than this threshold.
1002+
Values must be in the range `[0.0, inf)`.
9971003
9981004
n_jobs : int, default=None
9991005
The number of CPUs to use to do the OVA (One Versus All, for
@@ -1006,18 +1012,19 @@ class SGDClassifier(BaseSGDClassifier):
10061012
Used for shuffling the data, when ``shuffle`` is set to ``True``.
10071013
Pass an int for reproducible output across multiple function calls.
10081014
See :term:`Glossary <random_state>`.
1015+
Integer values must be in the range `[0, 2**32 - 1]`.
10091016
10101017
learning_rate : str, default='optimal'
10111018
The learning rate schedule:
10121019
10131020
- 'constant': `eta = eta0`
10141021
- 'optimal': `eta = 1.0 / (alpha * (t + t0))`
1015-
where t0 is chosen by a heuristic proposed by Leon Bottou.
1022+
where `t0` is chosen by a heuristic proposed by Leon Bottou.
10161023
- 'invscaling': `eta = eta0 / pow(t, power_t)`
1017-
- 'adaptive': eta = eta0, as long as the training keeps decreasing.
1024+
- 'adaptive': `eta = eta0`, as long as the training keeps decreasing.
10181025
Each time n_iter_no_change consecutive epochs fail to decrease the
10191026
training loss by tol or fail to increase validation score by tol if
1020-
early_stopping is True, the current learning rate is divided by 5.
1027+
`early_stopping` is `True`, the current learning rate is divided by 5.
10211028
10221029
.. versionadded:: 0.20
10231030
Added 'adaptive' option
@@ -1026,13 +1033,15 @@ class SGDClassifier(BaseSGDClassifier):
10261033
The initial learning rate for the 'constant', 'invscaling' or
10271034
'adaptive' schedules. The default value is 0.0 as eta0 is not used by
10281035
the default schedule 'optimal'.
1036+
Values must be in the range `(0.0, inf)`.
10291037
10301038
power_t : float, default=0.5
10311039
The exponent for inverse scaling learning rate [default 0.5].
1040+
Values must be in the range `(-inf, inf)`.
10321041
10331042
early_stopping : bool, default=False
10341043
Whether to use early stopping to terminate training when validation
1035-
score is not improving. If set to True, it will automatically set aside
1044+
score is not improving. If set to `True`, it will automatically set aside
10361045
a stratified fraction of training data as validation and terminate
10371046
training when validation score returned by the `score` method is not
10381047
improving by at least tol for n_iter_no_change consecutive epochs.
@@ -1044,6 +1053,7 @@ class SGDClassifier(BaseSGDClassifier):
10441053
The proportion of training data to set aside as validation set for
10451054
early stopping. Must be between 0 and 1.
10461055
Only used if `early_stopping` is True.
1056+
Values must be in the range `(0.0, 1.0)`.
10471057
10481058
.. versionadded:: 0.20
10491059
Added 'validation_fraction' option
@@ -1053,6 +1063,7 @@ class SGDClassifier(BaseSGDClassifier):
10531063
fitting.
10541064
Convergence is checked against the training loss or the
10551065
validation loss depending on the `early_stopping` parameter.
1066+
Integer values must be in the range `[1, max_iter)`.
10561067
10571068
.. versionadded:: 0.20
10581069
Added 'n_iter_no_change' option
@@ -1081,11 +1092,12 @@ class SGDClassifier(BaseSGDClassifier):
10811092
existing counter.
10821093
10831094
average : bool or int, default=False
1084-
When set to True, computes the averaged SGD weights across all
1095+
When set to `True`, computes the averaged SGD weights across all
10851096
updates and stores the result in the ``coef_`` attribute. If set to
10861097
an int greater than 1, averaging will begin once the total number of
10871098
samples seen reaches `average`. So ``average=10`` will begin
10881099
averaging after seeing 10 samples.
1100+
Integer values must be in the range `[1, n_samples]`.
10891101
10901102
Attributes
10911103
----------

0 commit comments

Comments
 (0)