
Plot ROC/PR curves for feature selection.
Source:R/visualizer-lib-feature-selection.R
plot_feature_selection_curve.Rd
Plot ROC/PR curves for feature selection 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.- eval_name
Name of
Evaluator
containing results to plot. IfNULL
, the data used for plotting is computed from scratch viaeval_fun
.- eval_fun
Character string, specifying the function used to compute the data used for plotting if
eval_name = NULL
. Ifeval_name
is notNULL
, this argument is ignored.- eval_fun_options
List of named arguments to pass to
eval_fun
.- 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.
- ...
Not used.
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 feature_selection_funs:
eval_feature_importance_funs
,
eval_feature_selection_curve_funs
,
eval_feature_selection_err_funs
,
plot_feature_importance()
,
plot_feature_selection_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"),
feature_info = lapply(
1:4,
FUN = function(i) {
tibble::tibble(
# feature names
feature = c("featureA", "featureB", "featureC"),
# true feature support
true_support = c(TRUE, FALSE, TRUE),
# estimated feature support
est_support = c(TRUE, FALSE, FALSE),
# estimated feature importance scores
est_importance = c(10, runif(2, min = -2, max = 2))
)
}
)
)
# generate example eval_results data
eval_results <- list(
ROC = summarize_feature_selection_curve(
fit_results,
curve = "ROC",
nested_cols = "feature_info",
truth_col = "true_support",
imp_col = "est_importance"
),
PR = summarize_feature_selection_curve(
fit_results,
curve = "PR",
nested_cols = "feature_info",
truth_col = "true_support",
imp_col = "est_importance"
)
)
# create summary ROC/PR plots using pre-computed evaluation results
roc_plt <- plot_feature_selection_curve(eval_results = eval_results,
eval_name = "ROC", curve = "ROC",
show = c("line", "ribbon"))
pr_plt <- plot_feature_selection_curve(eval_results = eval_results,
eval_name = "PR", curve = "PR",
show = c("line", "ribbon"))
# or alternatively, create the same plots directly from fit results
roc_plt <- plot_feature_selection_curve(fit_results = fit_results,
show = c("line", "ribbon"),
curve = "ROC",
eval_fun_options = list(
nested_cols = "feature_info",
truth_col = "true_support",
imp_col = "est_importance"
))
pr_plt <- plot_feature_selection_curve(fit_results = fit_results,
show = c("line", "ribbon"),
curve = "PR",
eval_fun_options = list(
nested_cols = "feature_info",
truth_col = "true_support",
imp_col = "est_importance"
))
# can customize plot (see plot_eval_constructor() for possible arguments)
roc_plt <- plot_feature_selection_curve(eval_results = eval_results,
eval_name = "ROC", curve = "ROC",
show = c("line", "ribbon"),
plot_by = ".dgp_name")