We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9ea4aba commit f9f68e3Copy full SHA for f9f68e3
category_encoders/target_encoder.py
@@ -1,6 +1,7 @@
1
"""Target Encoder"""
2
import numpy as np
3
import pandas as pd
4
+from scipy.special import expit
5
from category_encoders.ordinal import OrdinalEncoder
6
import category_encoders.utils as util
7
import warnings
@@ -261,5 +262,6 @@ def target_encode(self, X_in):
261
262
return X
263
264
def _weighting(self, n):
- # monotonically increasing function on n bounded between 0 and 1
265
- return 1 / (1 + np.exp(-(n - self.min_samples_leaf) / self.smoothing))
+ # monotonically increasing function of n bounded between 0 and 1
266
+ # sigmoid in this case, using scipy.expit for numerical stability
267
+ return expit((n - self.min_samples_leaf) / self.smoothing)
0 commit comments