Visualize importance scores

# S3 method for class 'importance_perm'
autoplot(
  object,
  top = Inf,
  metric = NULL,
  eval_time = NULL,
  type = "importance",
  ...
)

Arguments

object

A tibble of results from importance_perm().

top

An integer for how many terms to show. To define importance when there are multiple metrics, the rankings of predictors are computed across metrics and the average rank is used. In the case of tied rankings, all the ties are included.

metric

A character vector or NULL for which metric to plot. By default, all metrics will be shown via facets. Possible options are the entries in .metric column of the object.

eval_time

For censored regression models, a vector of time points at which the survival probability is estimated.

type

A character value. The default is "importance" which shows the overall signal-to-noise ration (i.e., mean divided by standard error). Alternatively, "difference" shows the mean difference value with standard error bounds.

...

Not used.

Value

A ggplot2 object.

Examples

if (!rlang::is_installed(c("modeldata", "recipes", "workflows"))) {
  library(modeldata)
  library(recipes)
  library(workflows)
  library(dplyr)

  data(ad_data, package = "modeldata")

  ad_rec <-
    recipe(Class ~ ., data = ad_data) %>%
    step_pca(all_numeric_predictors(), -male, -age, num_comp = 5) %>%
    step_dummy(all_factor_predictors()) %>%
    step_zv(all_predictors())

  ad_wflow <- workflow(ad_rec, logistic_reg())
  ad_fit <- fit(ad_wflow, data = ad_data)

  ###

  set.seed(392)
  imp_orig <- importance_perm(ad_fit, data = ad_data, type = "original")

  autoplot(imp_derv, top = 10)

  ###

  set.seed(392)
  imp_derv <- importance_perm(ad_fit, data = ad_data, type = "derived")

  autoplot(imp_derv)
  autoplot(imp_derv, metric = "brier_class", type = "difference")
}