diff --git a/h2o-r/h2o-package/R/models.R b/h2o-r/h2o-package/R/models.R index 7c1bf24a34c5..f6e4d509a4d8 100755 --- a/h2o-r/h2o-package/R/models.R +++ b/h2o-r/h2o-package/R/models.R @@ -1138,7 +1138,7 @@ h2o.make_metrics <- function(predicted, actuals, domain=NULL, distribution=NULL, predicted <- .validate.H2OFrame(predicted, required=TRUE) actuals <- .validate.H2OFrame(actuals, required=TRUE) weights <- .validate.H2OFrame(weights, required=FALSE) - treatment <- .validate.H2OFrame(treatment, required=FALSE) + treatment <- .validate.H2OFrame(treatment, required=TRUE) if (!is.character(auc_type)) stop("auc_type argument must be of type character") if (!(auc_type %in% c("MACRO_OVO", "MACRO_OVR", "WEIGHTED_OVO", "WEIGHTED_OVR", "NONE", "AUTO"))) { stop("auc_type argument must be MACRO_OVO, MACRO_OVR, WEIGHTED_OVO, WEIGHTED_OVR, NONE, AUTO") @@ -1150,6 +1150,7 @@ h2o.make_metrics <- function(predicted, actuals, domain=NULL, distribution=NULL, params$weights_frame <- h2o.getId(weights) } if (!is.null(treatment)) { + params$treatment_frame <- h2o.getId(treatment) if (!(auuc_type %in% c("qini", "lift", "gain", "AUTO"))) { stop("auuc_type argument must be gini, lift, gain or AUTO") } @@ -1175,7 +1176,7 @@ h2o.make_metrics <- function(predicted, actuals, domain=NULL, distribution=NULL, params[["domain"]] <- out } params["auc_type"] <- auc_type - url <- paste0("ModelMetrics/predictions_frame/",params$predictions_frame,"/actuals_frame/",params$actuals_frame) + url <- paste0("ModelMetrics/predictions_frame/",params$predictions_frame,"/actuals_frame/",params$actuals_frame,"/treatment_frame/",params$treatment_frame) res <- .h2o.__remoteSend(method = "POST", url, .params = params) model_metrics <- res$model_metrics metrics <- model_metrics[!(names(model_metrics) %in% c("__meta", "names", "domains", "model_category"))] diff --git a/h2o-r/tests/testdir_misc/runit_make_metrics_uplift_binomial.R b/h2o-r/tests/testdir_misc/runit_make_metrics_uplift_binomial.R index 1857820b55f9..c56634b99833 100644 --- a/h2o-r/tests/testdir_misc/runit_make_metrics_uplift_binomial.R +++ b/h2o-r/tests/testdir_misc/runit_make_metrics_uplift_binomial.R @@ -25,8 +25,9 @@ test.make_metrics_uplift_binomial <- function() { pred <- h2o.assign(h2o.predict(model,train)[,1],"pred") actual <- h2o.assign(train[,response],"act") treat <- h2o.assign(train[,treatment],"treatment") + print(treat) - m0 <- h2o.make_metrics(pred, actual, treatment=treatment) + m0 <- h2o.make_metrics(pred, actual, treatment=treat) print(m0) m1 <- h2o.performance(model, train) print(m1)