8000 removed unecessary option for cv · scikit-learn/scikit-learn@b8d97a5 · GitHub
[go: up one dir, main page]

Skip to content

Commit b8d97a5

Browse files
committed
removed unecessary option for cv
1 parent dcd4645 commit b8d97a5

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

sklearn/preprocessing/_target_encoder.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Authors: The scikit-learn developers
22
# SPDX-License-Identifier: BSD-3-Clause
33

4-
from numbers import Integral, Real
4+
from numbers import Real
55

66
import numpy as np
77

@@ -92,14 +92,24 @@ class TargetEncoder(OneToOneFeatureMixin, _BaseEncoder):
9292
more weight on the global target mean.
9393
If `"auto"`, then `smooth` is set to an empirical Bayes estimate.
9494
95-
cv : int or cross-validation generator, default=5
96-
Determines the number of folds in the :term:`cross fitting` strategy used in
97-
:meth:`fit_transform`. For classification targets, `StratifiedKFold` is used
98-
and for continuous targets, `KFold` is used.
95+
cv : int, cross-validation generator or an iterable, default=None
96+
Determines the cross-validation splitting strategy.
97+
Possible inputs for cv are:
9998
100-
If an integer is provided, it is the number of folds.
101-
If a cross-validation generator is provided, it should be compatible with
102-
scikit-learn's cross-validation interface.
99+
- None, to use the default 5-fold cross validation,
100+
- integer, to specify the number of folds in a `(Stratified)KFold`,
101+
- :term:`CV splitter`,
102+
- An iterable yielding (train, test) splits as arrays of indices.
103+
104+
For integer/None inputs, if the estimator is a classifier and ``y`` is
105+
either binary or multiclass,
106+
:class:`~sklearn.model_selection.StratifiedKFold` is used. In all other
107+
cases, :class:`~sklearn.model_selection.KFold` is used. These splitters
108+
are instantiated with `shuffle=False` so the splits will be the same
109+
across calls.
110+
111+
Refer :ref:`User Guide <cross_validation>` for the various
112+
cross-validation strategies that can be used here.
103113
104114
shuffle : bool, default=True
105115
Whether to shuffle the data in :meth:`fit_transform` before splitting into
@@ -195,10 +205,7 @@ class TargetEncoder(OneToOneFeatureMixin, _BaseEncoder):
195205
"categories": [StrOptions({"auto"}), list],
196206
"target_type": [StrOptions({"auto", "continuous", "binary", "multiclass"})],
197207
"smooth": [StrOptions({"auto"}), Interval(Real, 0, None, closed="left")],
198-
"cv": [
199-
Interval(Integral, 2, None, closed="left"),
200-
"cv_object",
201-
],
208+
"cv": ["cv_object"],
202209
"shuffle": ["boolean"],
203210
"random_state": ["random_state"],
204211
}

0 commit comments

Comments
 (0)
0