ggpdpPairs: ggpdpPairs

Description Usage Arguments Value Examples

View source: R/ggpdpPairs.R

Description

Creates a plot of the partial dependence of each of the variables in ggpairs plot style matrix

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
ggpdpPairs(
  task,
  model,
  method = "pdp",
  corrVal = FALSE,
  corrMethod = "p",
  parallel = FALSE,
  vars = NULL,
  colLow = "red",
  colMid = "yellow",
  colHigh = "blue",
  fitlims = NULL,
  gridsize = 10,
  class = 1,
  cardinality = 20,
  ...
)

Arguments

task

Task created from the mlr package, either regression or classification.

model

Any machine learning model.

method

"pdp" (default) or "ale"

corrVal

If TRUE, then display the correlation coefficient on top of scatterplot.

corrMethod

a character string indicating which correlation coefficient (or covariance) is to be computed. One of "pearson" (default), "kendall", or "spearman".

parallel

If TRUE then the method is executed in parallel.

vars

Variables to plot. Defaults to all predictors.

colLow

Colour to be used for low values.

colMid

Colour to be used for mid values.

colHigh

Colour to be used for low values.

fitlims

If supplied, should be a numeric vector of length 2, specifying the fit range.

gridsize

for the pdp/ale plots, defaults to 10.

class

For a classification model, show the probability of this class. Defaults to 1.

cardinality

Manually set the cardinality.

...

Not currently implemented.

Value

A ggpairs style plot displaying the partial dependence.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Run an mlr3 ranger model:
library(mlr3)
library(mlr3learners)
library(MASS)
Boston1 <- Boston[,c(4:6,8,13:14)]
Boston1$chas <- factor(Boston1$chas)
task <- TaskRegr$new(id = "Boston1", backend = Boston1, target = "medv")
learner = lrn("regr.ranger", importance = "permutation")
fit <- learner$train(task)
ggpdpPairs(task , fit)

Boston2 <- Boston1
Boston2$medv <- ggplot2::cut_interval(Boston2$medv, 3)
levels(Boston2$medv) <- c("lo","mid", "hi")
task = TaskClassif$new(id = "Boston2", backend = Boston2, target = "medv")
learner = lrn("classif.ranger", importance = "impurity")
fit <- learner$train(task)
ggpdpPairs(task , fit, class="hi")

AlanInglis/vivid documentation built on July 9, 2020, 1:53 a.m.