interactionPlot: interactionPlot

Description Usage Arguments Examples

View source: R/interactionPlot.R

Description

Plots a selected variable against all other variables in a model

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
interactionPlot(
  model,
  data,
  interactionType = "ice",
  pal = rev(sequential_hcl(palette = "Blues 3", n = 11)),
  fitlims = NULL,
  gridSize = 10,
  normalize = FALSE,
  n_max = 1000,
  seed = NULL,
  sqrt = FALSE,
  type = "lollipop",
  title = NULL,
  label = FALSE
)

Arguments

model

A machine learning model created from mlr3 task and learner.

interactionType

Are measures based on Friedman's H statistic ("H") or on "ice" curves?

pal

A vector of colors to show values, for use with scale_fill_gradientn

fitlims

Specifies the fit range for the color map for interaction strength.

gridSize

The size of the grid for evaluating the predictions.

normalize

Should the variances explained be normalized? Default is FALSE.

n_max

Maximum number of data rows to consider.

seed

An integer random seed used for subsampling.

sqrt

In order to reproduce Friedman's H statistic, resulting values are root transformed. Set to FALSE if squared values should be returned.

type

The type of plot to display, either "lollipop" (default) or "barplot".

title

A title to be placed on the plot

label

Only compatible with plotType = "barplot". If TRUE then the interaction value is displayed at the end of each bar.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Load in the data:
aq <- data.frame(airquality)
aq <- na.omit(aq)

# Run an mlr ranger model:
library(mlr3)
library(mlr3learners)
library(ranger)
aq_Task <- TaskRegr$new(id = "airQ", backend = aq, target = "Ozone")
aq_lrn <- lrn("regr.ranger", importance = "permutation")
aq_Mod <- aq_lrn$train(aq_Task)

# Create plot:
interactionPlot(aq_Task, aq_Mod)

AlanInglis/vividOld documentation built on March 4, 2021, 12:44 a.m.