pdp_ice_ale: Plot PD, ICE, and ALE curves

Description Usage Arguments Value Examples

View source: R/pdp_ice_ale.R

Description

This function allows to create PD, ICE, ALE plots ICE plots can be centered at the minimum Plots for several features of one model can be created at the same time

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
pdp_ice_ale(
  pred,
  features,
  method,
  xlabel = features,
  ylabel = method,
  title = "",
  center = FALSE,
  limits = c(NA, NA),
  nCol = NA,
  alpha = 0.5,
  sample_prop = 0.5
)

Arguments

pred

A prediction object from package iml

features

A character vector containing the names of the features for which the plot should be created

method

A character string indicating the method to be applied: either "pdp", "pdp+ice", "ice", or "ale"

xlabel

An optional character vector indicating x-axis label

ylabel

An optional character string indicating y-axis label

title

An optional character string indicating the title of the plot

center

Logical indicating whether ICE curves should be centered at the minimum. Default is FALSE

limits

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

nCol

An optional numeric entry indicating the number of columns when plots are created for several features

alpha

An optional numeric entry indicating the alpha-level of ICE curves

sample_prop

An optional numeric entry between 0 and 1 indicating the percentage of individiuals that should be sampled for ICE curves

Value

a plot of type ggplotify

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)
y <- 5 + 2 * x1 + x2 + rnorm(N,1)
dat <- data.frame(x1,x2,y)
rfmod <- randomForest::randomForest(y~., dat)
pred <- iml::Predictor$new(rfmod)
pdp <- pdp_ice_ale(pred,  "x1", method = "pdp")
ice <- pdp_ice_ale(pred,  "x1", method = "ice", alpha = .1)
pdp_ice <- pdp_ice_ale(pred,  "x1", method = "pdp+ice", alpha = .2)
ale <- pdp_ice_ale(pred,  c("x1", "x2"), method = "ale", ylabel = "ALE")

## End(Not run)

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