直接在R中实施自定义停止指标以在H2O模型训练期间进行优化 [英] Implementing custom stopping metrics to optimize during training in H2O model directly from R
问题描述
我正在尝试实现 FBeta_Score()
MLmetrics
R包:
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()
函数的帮助文档说:
in the H2O distributed random forest model and I want to optimize it during the training phase using the custom_metric_func
option.
The help documentation of the h2o.randomForest()
function says:
自定义评估功能的参考,格式: 'language:keyName = funcName'
Reference to custom evaluation function, format: 'language:keyName=funcName'
但是我不明白如何直接从R中使用它,以及我应该在stopping_metric
选项中指定的内容.
But I don't understand how to use it directly from R and what I should specify in the stopping_metric
option.
任何帮助将不胜感激!
推荐答案
Currently there is only backend support for Python-based custom functions, which can be uploaded to the backend via the h2o.upload_custom_metric() function. This function will then return a function reference (this is a string that has a naming convention format of 'language:keyName=funcName'
). That you can then pass to the custom_metric
parameter.
例如:
custom_mm_func = h2o.upload_custom_metric(CustomRmseFunc, func_name="rmse", func_file="mm_rmse.py")
返回具有以下值的函数引用:
returns a function reference which has the following value:
> print(custom_mm_func)
python:rmse=mm_rmse.CustomRmseFuncWrapper
关于将自定义指标用作停止指标的第二个问题,您可以在此处找到一张吉拉票: https://0xdata.atlassian.net/browse/PUBDEV-5261
As for your second question about using the custom metric as a stopping metric, there is a jira ticket that you can follow here: https://0xdata.atlassian.net/browse/PUBDEV-5261
您可以找到有关如何使用自定义指标的更多详细信息此处.
You can find more details on how to use the custom metric here.
这篇关于直接在R中实施自定义停止指标以在H2O模型训练期间进行优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!