Fra*_*cci 5 customization packages r random-forest h2o
我想实现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)
}
Run Code Online (Sandbox Code Playgroud)
在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")
Run Code Online (Sandbox Code Playgroud)
返回一个具有以下值的函数引用:
> print(custom_mm_func)
python:rmse=mm_rmse.CustomRmseFuncWrapper
Run Code Online (Sandbox Code Playgroud)
至于关于使用自定义指标作为停止指标的第二个问题,您可以在此处找到jira票证:https:///0xdata.atlassian.net/browse/PUBDEV-5261
您可以在此处找到有关如何使用自定义指标的更多详细信息.