Description Usage Arguments Details Value Note Author(s) References See Also Examples

Partial dependence plot gives a graphical depiction of the marginal effect of a variable on the class probability (classification) or response (regression).

1 2 3 4 5 6 7 |

`x` |
an object of class |

`pred.data` |
a data frame used for contructing the plot, usually the training data used to contruct the random forest. |

`x.var` |
name of the variable for which partial dependence is to be examined. |

`which.class` |
For classification data, the class to focus on (default the first class). |

`w` |
weights to be used in averaging; if not supplied, mean is not weighted |

`plot` |
whether the plot should be shown on the graphic device. |

`add` |
whether to add to existing plot ( |

`n.pt` |
if |

`rug` |
whether to draw hash marks at the bottom of the plot
indicating the deciles of |

`xlab` |
label for the x-axis. |

`ylab` |
label for the y-axis. |

`main` |
main title for the plot. |

`...` |
other graphical parameters to be passed on to |

The function being plotted is defined as:

*
\tilde{f}(x) = \frac{1}{n} ∑_{i=1}^n f(x, x_{iC}),
*

where *x* is the variable for which partial dependence is sought,
and *x_{iC}* is the other variables in the data. The summand is
the predicted regression function for regression, and logits
(i.e., log of fraction of votes) for `which.class`

for
classification:

* f(x) = \log p_k(x) - \frac{1}{K} ∑_{j=1}^K \log p_j(x),*

where *K* is the number of classes, *k* is `which.class`

,
and *p_j* is the proportion of votes for class *j*.

A list with two components: `x`

and `y`

, which are the values
used in the plot.

The `randomForest`

object must contain the `forest`

component; i.e., created with ```
randomForest(...,
keep.forest=TRUE)
```

.

This function runs quite slow for large data sets.

Andy Liaw andy\_liaw@merck.com

Friedman, J. (2001). Greedy function approximation: the gradient
boosting machine, *Ann. of Stat.*

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
data(iris)
set.seed(543)
iris.rf <- randomForest(Species~., iris)
partialPlot(iris.rf, iris, Petal.Width, "versicolor")
## Looping over variables ranked by importance:
data(airquality)
airquality <- na.omit(airquality)
set.seed(131)
ozone.rf <- randomForest(Ozone ~ ., airquality, importance=TRUE)
imp <- importance(ozone.rf)
impvar <- rownames(imp)[order(imp[, 1], decreasing=TRUE)]
op <- par(mfrow=c(2, 3))
for (i in seq_along(impvar)) {
partialPlot(ozone.rf, airquality, impvar[i], xlab=impvar[i],
main=paste("Partial Dependence on", impvar[i]),
ylim=c(30, 70))
}
par(op)
``` |

```
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.