Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is H2O target mean encoding available in Python?

Tags:

python

h2o

I noticed H2O has released the target mean encoding

http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-munging/target-encoding.html

It only comes with an R code example. Does anyone have a Python example?

like image 948
Gavin Avatar asked Jul 16 '26 08:07

Gavin


1 Answers

Like this:

from h2o.targetencoder import TargetEncoder

# Fit target encoding on training data
targetEncoder = TargetEncoder(x= ["addr_state", "purpose"], y = "bad_loan", fold_column = "cv_fold_te")
targetEncoder.fit(ext_train)

But this requires version at least 3.22

Here is a link to an example: https://github.com/h2oai/h2o-tutorials/blob/78c3766741e8cbbbd8db04d54b1e34f678b85310/best-practices/feature-engineering/feature_engineering.ipynb

And the link to code itself: https://github.com/h2oai/h2o-3/blob/master/h2o-py/h2o/targetencoder.py

like image 132
Andrey Lukyanenko Avatar answered Jul 17 '26 22:07

Andrey Lukyanenko