colored_ice: Plot colored ICE curves

Description Usage Arguments Value Examples

View source: R/colored_ice.R

Description

This function allows to plot colored ice predictions for a set of features, colored by a covariate

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
colored_ice(
  pred,
  features,
  covar,
  xlabel = features,
  ylabel = "",
  title = "",
  center = FALSE,
  limits = c(NA, NA),
  nCol = NA,
  colors = NULL,
  alpha = 1,
  legend_title = covar,
  legend_position = "right"
)

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

covar

A character string indicating the covariate after which the ICE curves should be colored

xlabel

An optional character string of the same length as the number of features indicating the x-axis label of the single plots

ylabel

An optional character string indicating y-axis label (same for all panels)

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

colors

An optional vector with entries for each level of 'covar'

alpha

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

legend_title

A character indicating the legend title. Default is the name of 'covar'

legend_position

Logical indicating whether the legend should be shown. Default is TRUE

Value

a plot of type ggplotify

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
N <- 1000
x1 <- runif(N, -1, 1)
x2 <- runif(N, -1, 1)
y <- 5 + 5 * x1 * x2 + rnorm(N,1)
dat <- data.frame(x1,x2,y)
rfmod <- randomForest::randomForest(y~., dat)
pred <- iml::Predictor$new(rfmod)
colored_ice(pred, features = "x1", covar = "x2")
colored_ice(pred, features = "x1", covar = "x2", center = TRUE)

## End(Not run)

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