View source: R/visualizer-lib-utils.R
get_plot_data | R Documentation |
A helper function to retrieve data for plotting in
Visualizers
. It first looks for the data in eval_results
by
name (eval_name
). If this is not provided, then it uses the
function + arguments specified by eval_fun
and
eval_fun_options
to compute the plotting data from
fit_results
.
get_plot_data(
fit_results = NULL,
eval_results = NULL,
eval_name = NULL,
eval_fun = NULL,
eval_fun_options = NULL
)
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 |
If eval_name
is not NULL
, returns the list
component in eval_results
named eval_name
. Otherwise,
returns the result of eval_fun()
.
# 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"),
# estimated feature importance scores
est_importance = c(10, runif(2, min = -2, max = 2))
)
}
)
)
# generate example eval_results data
eval_results <- list(
`Feature Importance` = summarize_feature_importance(
fit_results,
nested_cols = "feature_info",
feature_col = "feature",
imp_col = "est_importance"
)
)
# this will return the `Feature Importance` component of `eval_results`
plot_data1 <- get_plot_data(
fit_results = fit_results,
eval_results = eval_results,
eval_name = "Feature Importance"
)
#' # this will return the same result as above
plot_data2 <- get_plot_data(
fit_results = fit_results,
eval_fun = summarize_feature_importance,
eval_fun_options = list(
nested_cols = "feature_info",
feature_col = "feature",
imp_col = "est_importance"
)
)
all.equal(plot_data1, plot_data2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.