Description Usage Arguments Examples
Plot variable importance scores for the predictors in a model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 
object 
A fitted model object (e.g., a 
... 
Additional optional arguments to be passed on to 
num_features 
Integer specifying the number of variable importance
scores to plot. Default is 
geom 
Character string specifying which type of plot to construct. The currently available options are described below.

mapping 
Set of aesthetic mappings created by 
aesthetics 
List specifying additional arguments passed on to

horizontal 
Logical indicating whether or not to plot the importance
scores on the xaxis ( 
all_permutations 
Logical indicating whether or not to plot all
permutation scores along with the average. Default is 
jitter 
Logical indicating whether or not to jitter the raw permutation
scores. Default is 
include_type 
Logical indicating whether or not to include the type of
variable importance computed in the axis label. Default is 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42  #
# A projection pursuit regression example
#
# Load the sample data
data(mtcars)
# Fit a projection pursuit regression model
model < ppr(mpg ~ ., data = mtcars, nterms = 1)
# Construct variable importance plot
vip(model, method = "firm")
# Better yet, store the variable importance scores and then plot
vi_scores < vi(model, method = "firm")
vip(vi_scores, geom = "point", horiz = FALSE)
vip(vi_scores, geom = "point", horiz = FALSE, aesthetics = list(size = 3))
# The `%T>\%` operator is imported for convenience; see ?magrittr::`%T>%`
# for details
vi_scores < model %>%
vi(method = "firm") %T>%
{print(vip(.))}
vi_scores
# Permutation scores (barplot w/ raw values and jittering)
pfun < function(object, newdata) predict(object, newdata = newdata)
vip(model, method = "permute", train = mtcars, target = "mpg", nsim = 10,
metric = "rmse", pred_wrapper = pfun,
aesthetics = list(color = "grey50", fill = "grey50"),
all_permutations = TRUE, jitter = TRUE)
# Permutation scores (boxplot)
vip(model, method = "permute", train = mtcars, target = "mpg", nsim = 10,
metric = "rmse", pred_wrapper = pfun, geom = "boxplot")
# Permutation scores (boxplot colored by feature)
library(ggplot2) # for `aes_string()` function
vip(model, method = "permute", train = mtcars, target = "mpg", nsim = 10,
metric = "rmse", pred_wrapper = pfun, geom = "boxplot",
all_permutations = TRUE, mapping = aes_string(fill = "Variable"),
aesthetics = list(color = "grey35", size = 0.8))

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.