@@ -51,7 +51,7 @@ class TargetEncoder(BaseEstimator, util.TransformerWithTargetMixin):
51
51
>>> bunch = load_boston()
52
52
>>> y = bunch.target
53
53
>>> X = pd.DataFrame(bunch.data, columns=bunch.feature_names)
54
- >>> enc = TargetEncoder(cols=['CHAS', 'RAD']).fit(X, y)
54
+ >>> enc = TargetEncoder(cols=['CHAS', 'RAD'], min_samples_leaf=20, smoothing=10 ).fit(X, y)
55
55
>>> numeric_dataset = enc.transform(X)
56
56
>>> print(numeric_dataset.info())
57
57
<class 'pandas.core.frame.DataFrame'>
@@ -93,11 +93,13 @@ def __init__(self, verbose=0, cols=None, drop_invariant=False, return_df=True, h
93
93
self .min_samples_leaf = min_samples_leaf
94
94
if min_samples_leaf == 1 :
95
95
warnings .warn ("Default parameter min_samples_leaf will change in version 2.6."
96
- "See https://github.com/scikit-learn-contrib/category_encoders/issues/327" )
96
+ "See https://github.com/scikit-learn-contrib/category_encoders/issues/327" ,
97
+ category = FutureWarning )
97
98
self .smoothing = smoothing
98
99
if min_samples_leaf == 1.0 :
99
100
warnings .warn ("Default parameter smoothing will change in version 2.6."
100
- "See https://github.com/scikit-learn-contrib/category_encoders/issues/327" )
101
+ "See https://github.com/scikit-learn-contrib/category_encoders/issues/327" ,
102
+ category = FutureWarning )
101
103
self ._dim = None
102
104
self .mapping = None
103
105
self .handle_unknown = handle_unknown
@@ -177,6 +179,7 @@ def fit_target_encoding(self, X, y):
177
179
178
180
smoove = 1 / (1 + np .exp (- (stats ['count' ] - self .min_samples_leaf ) / self .smoothing ))
179
181
smoothing = prior * (1 - smoove ) + stats ['mean' ] * smoove
182
+ # @ToDo delete this in version 2.6
180
183
smoothing [stats ['count' ] == 1 ] = prior
181
184
182
185
if self .handle_unknown == 'return_nan' :
0 commit comments