R/find_y.R

Defines functions find_y.default find_y.NULL find_y.H2ORegressionModel find_y.H2OBinomialModel find_y.H2OMultinomialModel find_y.WrappedModel find_y

#' @importFrom stats formula terms
find_y <- function(mod) {
  if (is.null(mod)) {
    return(NULL)
  }
  UseMethod("find_y")
}

find_y.WrappedModel <- function(mod) {
  mod$task.desc$target
}

find_y.H2OMultinomialModel <- function(mod) {
  mod@parameters$y
}

find_y.H2OBinomialModel <- function(mod) {
  mod@parameters$y
}

find_y.H2ORegressionModel <- function(mod) {
  mod@parameters$y
}


find_y.NULL <- function(mod) {
  NULL
}

find_y.default <- function(mod) {
  fml <- tryCatch(Formula::as.Formula(formula(mod)), error = function(e) NULL)
  if (is.null(fml)) {
    return(NULL)
  }
  target <- terms(fml, lhs = 1, rhs = 0)
  ix <- attr(target, "variables")[-1L]
  y <- sapply(ix, deparse, width.cutoff = 500L)
  y
}

Try the iml package in your browser

Any scripts or data that you put into this service are public.

iml documentation built on May 29, 2024, 1:59 a.m.