Plot ROC/PR curves or some summary thereof across experimental replicates.
Arguments
- fit_results
A tibble, as returned by the
fit
method.- eval_results
A list of result tibbles, as returned by the
evaluate
method.- evaluator_name
Name of
Evaluator
containing results to plot. To compute the evaluation summary results from scratch or if the evaluation summary results have not yet been evaluated, set toNULL
.- vary_params
A vector of parameter names that are varied across in the
Experiment
.- curve
Either "ROC" or "PR" indicating whether to plot the ROC or Precision-Recall curve.
- show
Character vector with elements being one of "boxplot", "point", "line", "bar", "errorbar", "ribbon" indicating what plot layer(s) to construct.
- ...
Additional arguments to pass to
plot_eval_summary()
. This includes arguments for plotting and for passing intosummarize_pred_curve()
.
Value
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
.
See also
Other prediction_error_funs:
eval_pred_curve_funs
,
eval_pred_err_funs
,
plot_pred_err()
Examples
# 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) {
as.factor(sample(0:1, size = 100, replace = TRUE))
}),
# predicted class probabilities
class_probs = lapply(1:4, FUN = function(x) runif(n = 100, min = 0, max = 1))
)
# generate example eval_results data
eval_results <- list(
ROC = summarize_pred_curve(
fit_results, truth_col = "y", prob_cols = "class_probs", curve = "ROC"
),
PR = summarize_pred_curve(
fit_results, truth_col = "y", prob_cols = "class_probs", curve = "PR"
)
)
# create summary ROC/PR plots using pre-computed evaluation results
roc_plt <- plot_pred_curve(fit_results = fit_results, eval_results = eval_results,
evaluator_name = "ROC", curve = "ROC",
show = c("line", "ribbon"))
pr_plt <- plot_pred_curve(fit_results = fit_results, eval_results = eval_results,
evaluator_name = "PR", curve = "PR",
show = c("line", "ribbon"))
# or alternatively, create the same plots without pre-computing evaluation results
roc_plt <- plot_pred_curve(fit_results, show = c("line", "ribbon"),
truth_col = "y", prob_cols = "class_probs",
curve = "ROC")
pr_plt <- plot_pred_curve(fit_results, show = c("line", "ribbon"),
truth_col = "y", prob_cols = "class_probs",
curve = "PR")
# can customize plot (see plot_eval_summary() for possible arguments)
roc_plt <- plot_pred_curve(fit_results = fit_results, eval_results = eval_results,
evaluator_name = "ROC", curve = "ROC",
show = c("line", "ribbon"),
plot_by = ".dgp_name")