Skip to content

Commit

Permalink
fix make metrics runit
Browse files Browse the repository at this point in the history
  • Loading branch information
maurever committed Aug 9, 2023
1 parent 1c4b898 commit c1afde4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions h2o-r/h2o-package/R/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
}
Expand All @@ -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"))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c1afde4

Please sign in to comment.