@@ -92,11 +92,15 @@ class TargetEncoder(OneToOneFeatureMixin, _BaseEncoder):
92
92
more weight on the global target mean.
93
93
If `"auto"`, then `smooth` is set to an empirical Bayes estimate.
94
94
95
- cv : int, default=5
95
+ cv : int or cross-validation generator , default=5
96
96
Determines the number of folds in the :term:`cross fitting` strategy used in
97
97
:meth:`fit_transform`. For classification targets, `StratifiedKFold` is used
98
98
and for continuous targets, `KFold` is used.
99
99
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.
103
+
100
104
shuffle : bool, default=True
101
105
Whether to shuffle the data in :meth:`fit_transform` before splitting into
102
106
folds. Note that the samples within each split will not be shuffled.
@@ -191,7 +195,10 @@ class TargetEncoder(OneToOneFeatureMixin, _BaseEncoder):
191
195
"categories" : [StrOptions ({"auto" }), list ],
192
196
"target_type" : [StrOptions ({"auto" , "continuous" , "binary" , "multiclass" })],
193
197
"smooth" : [StrOptions ({"auto" }), Interval (Real , 0 , None , closed = "left" )],
194
- "cv" : [Interval (Integral , 2 , None , closed = "left" )],
198
+ "cv" : [
199
+ Interval (Integral , 2 , None , closed = "left" ),
200
+ "cv_object" ,
201
+ ],
195
202
"shuffle" : ["boolean" ],
196
203
"random_state" : ["random_state" ],
197
204
}
0 commit comments