permutation_importance: Plot permutation importance

Description Usage Arguments Value Examples

View source: R/permutation_importance.R

Description

This function allows to plot permutation importance based on mean squared error. Three types are implemented: model-based permutation importance, random forest permutation importnance or conditional random forest variable importance

Usage

1
2
3
4
5
6
7
8
9
permutation_importance(
  object,
  type,
  loss = NULL,
  xlabel = "",
  ylabel = type,
  title = "",
  limits = c(NA, NA)
)

Arguments

object

A prediction object from package iml for model-based permutation importance or an object as returned by randomForest or cforest

type

A character indicating the type of variable importance: model-agnostic, randomforest, or conditional

loss

A character specifying the loss function for type = model-agnostic. See ?iml::FeatureImp for more details

xlabel

An optional character string indicating the x-axis label

ylabel

An optional character string indicating the y-axis label

title

An optional character string indicating the title of the plot

limits

An optional two-entry vector indicating the limits of the y-axis

Value

a plot of type ggplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
N <- 1000
x1 <- runif(N, -1, 1)
x2 <- runif(N, -1, 1)
x3 <- x2 + runif(N, -1, 1)
y <- 5 + 5 * x1 + 5 * x2 + 0 * x3 + rnorm(N,1)
dat <- data.frame(x1,x2,x3,y)
rfmod <- randomForest::randomForest(y~., dat)
pred <- iml::Predictor$new(rfmod)
permutation_importance(pred, type = "model-agnostic", limits = c(0,18), loss = "mse")
permutation_importance(rfmod, type = "randomforest", limits = c(0,18))
permutation_importance(rfmod, type = "conditional", limits = c(0,18))

## End(Not run)

mirka-henninger/InterpretationMethods documentation built on Jan. 12, 2022, 4:10 p.m.