plot_variable_transition: Plot variable profile

Description Usage Arguments Examples

View source: R/utils-model.R

Description

The function plots variable profile. In case of quantiitative variable it plots original transition function and its spline approximation. The function provides possibility to plot data points and transition derivative as well. In case of qualitative variable it plots merging path for variable levels. When no variable is specified it plots transitions for first n_plots variables.

Usage

1
2
3
4
plot_variable_transition(x, variable_names = NULL,
  plot_response = TRUE, plot_approx = TRUE, data = NULL,
  plot_data = FALSE, plot_deriv = FALSE, n_plots = 6,
  use_coeff = TRUE)

Arguments

x

Object of class 'xspliner'.

variable_names

Names of predictors which transitions should be plotted.

plot_response

If TRUE black box model response is drawn.

plot_approx

If TRUE black box model response approximation is drawn.

data

Training data used for building x model. Required for plot_data option.

plot_data

If TRUE raw data is drawn.

plot_deriv

If TRUE derivative of approximation is showed on plot.

n_plots

Threshold for number of plots when plotting all variables.

use_coeff

If TRUE both PDP function and its approximation is scaled with corresponding surrogate model coefficient.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(randomForest)
set.seed(1)
data <- iris
# regression model
iris.rf <- randomForest(Petal.Width ~  Sepal.Length + Petal.Length + Species, data = data)
iris.xs <- xspline(iris.rf)
# plot Sepal.Length transition
plot_variable_transition(iris.xs, "Sepal.Length")
# plot Species transition
plot_variable_transition(iris.xs, "Species")
# plot all transitions
plot_variable_transition(iris.xs)
# plot Sepal.Length transition, its derivative and data points
plot_variable_transition(iris.xs, "Sepal.Length", data = data, plot_data = TRUE, plot_deriv = TRUE)

krystian8207/xspliner documentation built on Oct. 6, 2019, 11:02 p.m.