scikit-learn-contrib / category_encoders

A library of sklearn compatible categorical variable encoders
http://contrib.scikit-learn.org/category_encoders/
BSD 3-Clause "New" or "Revised" License
2.4k stars 393 forks source link

FloatingPointError: underflow encountered in exp #377

Closed CoteDave closed 1 year ago

CoteDave commented 1 year ago

catboost version: 2.5.1 numpy version: 1.23.3

image

t_encoder= TargetEncoder(min_samples_leaf=20, smoothing=10) t_encoded = t_encoder.fit_transform(new_xy_test_dummy[[cat_col]].astype(str), new_xy_test_dummy[[target_col]], cols = [cat_col])

No nans...

Same data seems to work with WOE encoder. Encountered the problem only with TargetEncoder: w_encoder= WOEEncoder() w_encoded = w_encoder.fit_transform(new_xy_test_dummy[[cat_col]].astype(str), new_xy_test_dummy[[target_col]], cols = [cat_col]) = works!

Any Ideas ?

Thanks !

PaulWestenthanner commented 1 year ago

can you please provide some data in order to reproduce this and also format your code as code (for better readability)

glevv commented 1 year ago

There is an easy and long awaited fix.

But we still need data example (or specific values, in this case very small ones) for testing purposes.