get_perm_int <- function(dat, mod_eval, mod, features, formula, verbose) {
plyr::llply(features, feature_perm_int, dat, mod_eval, mod, formula,
.progress = if (verbose) "text" else "none") %>%
dplyr::bind_rows()
}
# Permute the feature, keep the model the same,
# and evaluate the model.
feature_perm_int <- function(feature, dat, mod_eval, mod, formula) {
dat[[feature]] <- sample(dat[[feature]], size = nrow(dat), replace = FALSE)
eval_mod(mod, dat) %>%
{.$summary} %>%
{mod_eval$summary - .} %>%
tibble::add_column(feature = feature, .before = 1) %>%
dplyr::select(- .data$num_options) %>%
tibble::as_tibble()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.