View source: R/evaluator-lib-utils.R
eval_constructor | R Documentation |
Helper function for developing a new Evaluator
that evaluates some function (e.g., metric) for each row in
fit_results
.
eval_constructor(
fit_results,
vary_params = NULL,
fun,
nested_cols = NULL,
...,
group_cols = NULL,
fun_options = NULL,
na_rm = FALSE
)
fit_results |
A tibble, as returned by |
vary_params |
A vector of |
fun |
Function to compute for each row in |
nested_cols |
(Optional) A character string or vector specifying the
name of the column(s) in |
... |
Named arguments, containing names of columns to pass to
|
group_cols |
(Optional) A character string or vector specifying the column(s) to group rows by before evaluating metrics. This is useful for assessing within-group metrics. |
fun_options |
Named list of additional arguments to pass to |
na_rm |
A |
# generate example fit_results data for a regression problem
fit_results <- tibble::tibble(
.rep = rep(1:2, times = 2),
.dgp_name = c("DGP1", "DGP1", "DGP2", "DGP2"),
.method_name = c("Method"),
# true response
y = lapply(1:4, FUN = function(x) rnorm(100)),
# predicted response
predictions = lapply(1:4, FUN = function(x) rnorm(100))
)
# evaluate root mean squared error for each row in fit_results
rmse_fun <- function(data, truth_col, estimate_col, na_rm = TRUE) {
yardstick::rmse_vec(
data[[truth_col]], data[[estimate_col]], na_rm = na_rm
)
}
eval_results <- eval_constructor(
fit_results = fit_results,
fun = rmse_fun,
truth_col = "y",
estimate_col = "predictions"
) %>%
tidyr::unnest(.eval_result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.