Python 中是否提供 H2O 目标均值编码?

Is H2O target mean encoding available in Python?

我注意到 H2O 发布了目标均值编码

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

它只附带一个R代码示例。有人有 Python 例子吗?

像这样:

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)

但这需要版本至少为 3.22

下面是一个link的例子:https://github.com/h2oai/h2o-tutorials/blob/78c3766741e8cbbbd8db04d54b1e34f678b85310/best-practices/feature-engineering/feature_engineering.ipynb

然后 link 自己编码:https://github.com/h2oai/h2o-3/blob/master/h2o-py/h2o/targetencoder.py