R/score.R

Defines functions score.default score

Documented in score score.default

# -----------------------------------------------------------------------------
# ---------------------- Model fit generic interface --------------------------
# -----------------------------------------------------------------------------

#' A scoring function
#'
#' @param object Depending on the context:
#'
#'   * A __data frame__ of predictors.
#'   * A __matrix__ of predictors.
#'   * A __recipe__ specifying a set of preprocessing steps
#'     created from [recipes::recipe()].
#'
#' @param ... Not currently used, but required for extensibility.
#'
#' @return
#'
#' A tibble of predictions.
#'
#' @export
score <- function(object, ...) {
  UseMethod("score")
}

#' @export
#' @export score.default
#' @rdname score
score.default <- function(object, ...) {
  cls <- class(object)[1]
  message <-
    "`object` is not of a recognized type.
     Only data.frame, matrix, recipe, and formula objects are allowed.
     A {cls} was specified."
  message <- glue::glue(message)
  rlang::abort(message = message)
}

Try the applicable package in your browser

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

applicable documentation built on Aug. 21, 2022, 1:06 a.m.