twoD_pdp_ale: Plot two-dimensional pdp, ice, ale

Description Usage Arguments Value Examples

View source: R/twoD_pdp_ale.R

Description

This function allows to plot 2-dimensional pdp, ale figures. Please note ale for two categorical features is not yet implemented, and that the categorical feature must be placed on the x-axis.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
twoD_pdp_ale(
  pred,
  features,
  method,
  title = "",
  xlabel = features[1],
  ylabel = features[2],
  limits = c(NA, NA),
  show_data = FALSE,
  legend_position = "right",
  rugs = TRUE
)

Arguments

pred

A prediction object from package iml

features

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

title

An optional character string indicating the title of the plot

xlabel

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

ylabel

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

limits

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

show_data

Logical indicating whether datapoints should be plotted. Default is FALSE

legend_position

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

rugs

Logical indicating whether rugs 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)
(twoD_pdPlot <- twoD_pdp_ale(pred, features = c("x1", "x2"), method = "pdp"))
(twoD_alePlot <- twoD_pdp_ale(pred, features = c("x1", "x2"), method = "ale"))

## End(Not run)

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