R/determine_pred_type.R

Defines functions determine_pred_type

Documented in determine_pred_type

#' determine pred type
#'
#' @param x  a vector
#' @keywords internal
#'
#' @return a string
#'
determine_pred_type <- function(x){

  x %>% dplyr::n_distinct() -> target_levels
  x %>% is.numeric() -> is_tg_numeric

  if(target_levels <= 2){

    type <- "binary"

  } else if(is_probability(x)){

    type <- "binaryprob"}

  else if(target_levels > 2 & !is_tg_numeric){

    type <- "multiclass"
  } else {

    type <- "numeric"
    }
  type
}

Try the autostats package in your browser

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

autostats documentation built on Nov. 10, 2022, 6:13 p.m.