@@ -51,7 +51,7 @@ class TargetEncoder(BaseEstimator, util.TransformerWithTargetMixin):
5151 >>> bunch = load_boston()
5252 >>> y = bunch.target
5353 >>> 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)
5555 >>> numeric_dataset = enc.transform(X)
5656 >>> print(numeric_dataset.info())
5757 <class 'pandas.core.frame.DataFrame'>
@@ -93,11 +93,13 @@ def __init__(self, verbose=0, cols=None, drop_invariant=False, return_df=True, h
9393 self .min_samples_leaf = min_samples_leaf
9494 if min_samples_leaf == 1 :
9595 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 )
9798 self .smoothing = smoothing
9899 if min_samples_leaf == 1.0 :
99100 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 )
101103 self ._dim = None
102104 self .mapping = None
103105 self .handle_unknown = handle_unknown
@@ -177,6 +179,7 @@ def fit_target_encoding(self, X, y):
177179
178180 smoove = 1 / (1 + np .exp (- (stats ['count' ] - self .min_samples_leaf ) / self .smoothing ))
179181 smoothing = prior * (1 - smoove ) + stats ['mean' ] * smoove
182+ # @ToDo delete this in version 2.6
180183 smoothing [stats ['count' ] == 1 ] = prior
181184
182185 if self .handle_unknown == 'return_nan' :
0 commit comments