nico
nico

Reputation: 35

Multiple partial dependence plots in one graph

I am using the randomForest package with the Partialplot function.

I want to make multiple partial dependence plots in one graph. My thesis promotor told me that it is possible to save them (in the environment, I did this and I got a list object with 'x' and 'y' variables in that list), but I don't know how to recall the graph after saving it.

What I want to do is:

1. Save PD plots

2. recall them

3. plot multiple PDP in one graph

Upvotes: 2

Views: 3039

Answers (2)

Stephen Milborrow
Stephen Milborrow

Reputation: 1016

Instead of using the partialPlot function, consider using the plotmo function in the plotmo package. This will draw plots for all variables and variable pairs on a single page. For example:

library(randomForest)
data(trees)
mod <- randomForest(Volume~., data=trees)
library(plotmo)
plotmo(mod, pmethod="partdep") # plot partial dependencies

which gives

plot

You can specify exactly which variable and variable pairs get plotted using plotmo's all1, all2, degree1 and degree2 arguments. Additional examples are in the vignette for the plotmo package.

Upvotes: 1

bgreenwell
bgreenwell

Reputation: 413

Use the pdp package. Examples are given in the paper: https://journal.r-project.org/archive/2017/RJ-2017-016/RJ-2017-016.pdf.

Upvotes: 1

Related Questions