繁体   English   中英

实施自定义停止指标以直接从R中在H2O模型的训练期间进行优化

[英]Implementing custom stopping metrics to optimize during training in H2O model directly from R

我正在尝试实现MLmetrics R包FBeta_Score()

FBeta_Score <- function(y_true, y_pred, positive = NULL, beta = 1) {
   Confusion_DF <- ConfusionDF(y_pred, y_true)
   if (is.null(positive) == TRUE) 
   positive <- as.character(Confusion_DF[1,1])
   Precision <- Precision(y_true, y_pred, positive)
   Recall <- Recall(y_true, y_pred, positive)
   Fbeta_Score <- (1 + beta^2) * (Precision * Recall) / (beta^2 * Precision + 
   Recall)
   return(Fbeta_Score)
 }

H2O分布式随机森林模型中 ,我想在训练阶段使用custom_metric_func选项对其进行优化。 h2o.randomForest()函数的帮助文档说:

参考自定义评估函数,格式为:'language:keyName = funcName'

但我不明白如何直接从R中使用它以及我应该在stopping_metric选项中指定的内容。

任何帮助,将不胜感激!

目前只有基于Python的自定义函数的后端支持,可以通过h2o.upload_custom_metric()函数上传到后端。 然后,此函数将返回一个函数引用(这是一个字符串,其命名约定格式为'language:keyName=funcName' )。 然后,您可以传递给custom_metric参数。

例如:

custom_mm_func = h2o.upload_custom_metric(CustomRmseFunc, func_name="rmse", func_file="mm_rmse.py")

返回一个具有以下值的函数引用:

> print(custom_mm_func)
python:rmse=mm_rmse.CustomRmseFuncWrapper

至于关于使用自定义指标作为停止指标的第二个问题,您可以在此处找到jira票证: https///0xdata.atlassian.net/browse/PUBDEV-5261

您可以在此处找到有关如何使用自定义指标的更多详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM