Variable importance plots (VIPs) for R: quantify and visualize which features drive a fitted model's predictions.
vi() and vip() work with dozens of
model classes out of the box (randomForest, ranger, gbm, xgboost, lightgbm,
glmnet, caret, tidymodels, mlr3, …)method = "model"), permutation importance (method = "permute"),
Shapley-based importance (method = "shap"), and variance-based importance
(method = "firm")vip is no longer available on CRAN due to CRAN's stringent and ever-changing policies. It is now hosted on r-universe, which provides a reliable alternative for distributing R packages.
# Latest stable release (recommended)
install.packages("vip", repos = c("https://bgreenwell.r-universe.dev", "https://cloud.r-project.org"))
# Or with pak
pak::pak("bgreenwell/vip@main") # latest stable release
pak::pak("bgreenwell/vip") # development version (devel branch)
CRAN will archive the last CRAN release of vip (0.4.6) on 2026-07-13; all future releases live on r-universe (see above). vip 0.5.0 is also a breaking release — the main changes if you're coming from 0.4.x:
vip() (and the new
plot() method for "vi" objects) draws via
tinyplot and invisibly returns the
"vi" object, so vip(fit) + theme_bw() no longer works. Style plots with
graphical parameters instead — plot(vi(fit), type = "point", col = "red")
— or build your own ggplot from the tidy data frame that vi() returns.vi() returns a plain data frame (class "vi"), not a tibble; call
tibble::as_tibble() on the result if you need one.aesthetics is deprecated in favor of plot_args in vip(); the
ggplot2-era mapping argument is ignored with a warning; geom = "col"
still works as an alias for geom = "bar".Suggests, use
it conditionally (requireNamespace("vip", quietly = TRUE)), and declare
Additional_repositories: https://bgreenwell.r-universe.dev in your
DESCRIPTION — CRAN accepts this for Suggests-level dependencies.See NEWS.md for the complete list.
library(vip)
# Simulate Friedman 1 benchmark data; only x1-x5 are important!
trn <- gen_friedman(500, seed = 101) # ?vip::gen_friedman
# Model-specific importance from a random forest
library(ranger)
set.seed(101)
rfo <- ranger(y ~ ., data = trn, importance = "impurity")
vi(rfo) # data frame of variable importance scores
vip(rfo) # variable importance plot
# Permutation importance works for ANY model; just supply a prediction wrapper
pfun <- function(object, newdata) predict(object, data = newdata)$predictions
set.seed(102)
vis <- vi(rfo, method = "permute", train = trn, target = "y", metric = "rmse",
pred_wrapper = pfun, nsim = 10)
# "vi" objects have a plot() method; additional arguments are passed on to
# tinyplot::tinyplot()
plot(vis, type = "boxplot", all_permutations = TRUE, jitter = TRUE,
fill = "grey90")
vi() returns a tidy data frame of importance scores, so results are easy to
post-process or plot with any graphics package.
citation("vip"))Development happens on the devel
branch (the repository default); main holds stable releases, which is what
r-universe builds and the website documents. Please open pull requests against
devel and report bugs via the
issue tracker.