-
Notifications
You must be signed in to change notification settings - Fork 7
/
score.R
36 lines (34 loc) · 1017 Bytes
/
score.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -----------------------------------------------------------------------------
# ---------------------- 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)
}