View source: R/visualizer-lib-prediction.R
plot_pred_err | R Documentation |
Plot the raw or summarized prediction errors as a boxplot, scatter plot, line plot, or bar plot with or without 1 SD error bars.
plot_pred_err(
fit_results = NULL,
eval_results = NULL,
eval_name = NULL,
eval_fun = "summarize_pred_err",
eval_fun_options = NULL,
vary_params = NULL,
metrics = NULL,
show = c("point", "line"),
...
)
fit_results |
A tibble, as returned by |
eval_results |
A list of result tibbles, as returned by
|
eval_name |
Name of |
eval_fun |
Character string, specifying the function used to compute
the data used for plotting if |
eval_fun_options |
List of named arguments to pass to |
vary_params |
A vector of |
metrics |
A |
show |
Character vector with elements being one of "boxplot", "point", "line", "bar", "errorbar", "ribbon", "violin", indicating what plot layer(s) to construct. |
... |
Arguments passed on to
|
If interactive = TRUE
, returns a plotly
object if
plot_by
is NULL
and a list of plotly
objects if
plot_by
is not NULL
. If interactive = FALSE
, returns
a ggplot
object if plot_by
is NULL
and a list of
ggplot
objects if plot_by
is not NULL
.
Other prediction_error_funs:
eval_pred_curve_funs
,
eval_pred_err_funs
,
plot_pred_curve()
# generate example fit_results data
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))
)
# generate example eval_results data
eval_results <- list(
`Prediction Errors` = summarize_pred_err(
fit_results, truth_col = "y", estimate_col = "predictions"
)
)
# create errorbar plot using pre-computed evaluation results
plt <- plot_pred_err(eval_results = eval_results,
eval_name = "Prediction Errors",
show = c("point", "errorbar"))
# or alternatively, create the same plot directly from fit results
plt <- plot_pred_err(fit_results = fit_results,
show = c("point", "errorbar"),
eval_fun_options = list(truth_col = "y",
estimate_col = "predictions"))
# can customize plot (see plot_eval_constructor() for possible arguments)
plt <- plot_pred_err(fit_results = fit_results, eval_results = eval_results,
eval_name = "Prediction Errors",
show = c("point", "errorbar"),
color_str = NULL,
facet_formula = .method_name ~ .metric,
facet_type = "grid")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.