首页 > 解决方案 > R h2o:如何为 GBM 实现自定义停止度量

问题描述

我发现现在可以使用stopping_metric = customin h2o v3.22.1.1(在 中不可用v3.10.0.9),但是我没有找到如何在 R 中实现它的任何地方。

这是问题的玩具版本。

library(h2o)
h2o.init()
x <- data.frame(
   x = rnorm(1000),
   z = rnorm(1000), 
   y = factor(sample(0:1, 1000, replace = T))
)
train <- as.h2o(x)
h2o.gbm(x = c('x','z'), y = 'y', training_frame = train, stopping_metric = 'custom', stopping_rounds = 3)

我得到的错误如下:

Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = page,  : 


ERROR MESSAGE:

Illegal argument(s) for GBM model: GBM_model_R_1548836369139_123.  Details: ERRR on field: _stopping_metric: Custom metric function needs to be defined in order to use it for early stopping.

如何custom stopping_metric为 GBM 定义?

标签: rmachine-learningh2o

解决方案


R API 目前不提供此功能。如果这是您感兴趣的功能,我会在此处为您的用例创建一个 JIRA 。您可以使用Darren指出的另一个 SO 问题,以获取有关如何通过 Python API 使用此功能的信息。


推荐阅读