colored_pdp: Plot colored PD curves

Description Usage Arguments Value Examples

View source: R/colored_pdp.R

Description

This function allows to plot colored pd predictions for one feature, colored by a covariate

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
colored_pdp(
  pred,
  feature,
  covar,
  xlabel = feature,
  ylabel = "",
  title = "",
  legend_title = covar,
  legend_position = "right"
)

Arguments

pred

A prediction object from package iml

feature

A character vector containing the names of the feature 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 feature 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

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 <- sample(0:1, N, replace = TRUE)
x2 <- runif(N, -1, 1)
y <- 5 + 5 * x1 * x2 + rnorm(N,1)
x1 <- factor(x1)
dat <- data.frame(x1,x2,y)
rfmod <- randomForest::randomForest(y~., dat)
pred <- iml::Predictor$new(rfmod)
colored_pdp(pred, feature = "x2", covar = "x1")

## End(Not run)

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