plot_predict_interaction: Plot the prediction of the forest for a grid of values of two...

Description Usage Arguments Value Examples

Description

Plot the prediction of the forest for a grid of values of two numerical variables

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plot_predict_interaction(
  forest,
  data,
  variable1,
  variable2,
  grid = 100,
  main = paste0("Prediction of the forest for different values of ", paste0(variable1,
    paste0(" and ", variable2))),
  time = NULL
)

Arguments

forest

A randomForest or ranger object

data

The data frame on which forest was trained

variable1

A character string with the name a numerical predictor that will on X-axis

variable2

A character string with the name a numerical predictor that will on Y-axis

grid

The number of points on the one-dimensional grid on x and y-axis

main

A string to be used as title of the plot

time

A numeric value specifying the time at which to predict survival probability, only applies to survival forests. If not specified, the time closest to predicted median survival time is used

Value

A ggplot2 object

Examples

1
2
3
4
forest <- randomForest::randomForest(Species ~., data = iris)
plot_predict_interaction(forest, iris, "Petal.Width", "Sepal.Width")
forest_ranger <- ranger::ranger(Species ~., data = iris)
plot_predict_interaction(forest, iris, "Petal.Width", "Sepal.Width")

randomForestExplainer documentation built on July 12, 2020, 1:06 a.m.