partialPlot {RRF} | R Documentation |
Partial dependence plot
Description
Partial dependence plot gives a graphical depiction of the marginal effect of a variable on the class probability (classification) or response (regression).
Usage
## S3 method for class 'RRF'
partialPlot(x, pred.data, x.var, which.class,
w, plot = TRUE, add = FALSE,
n.pt = min(length(unique(pred.data[, xname])), 51),
rug = TRUE, xlab=deparse(substitute(x.var)), ylab="",
main=paste("Partial Dependence on", deparse(substitute(x.var))),
...)
Arguments
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 |
Details
The function being plotted is defined as:
where is the variable for which partial dependence is sought,
and
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:
where is the number of classes,
is
which.class
,
and is the proportion of votes for class
.
Value
A list with two components: x
and y
, which are the values
used in the plot.
Note
The RRF
object must contain the forest
component; i.e., created with RRF(...,
keep.forest=TRUE)
.
This function runs quite slow for large data sets.
Author(s)
Andy Liaw andy_liaw@merck.com
References
Friedman, J. (2001). Greedy function approximation: the gradient boosting machine, Ann. of Stat.
See Also
Examples
data(airquality)
airquality <- na.omit(airquality)
set.seed(131)
ozone.rf <- RRF(Ozone ~ ., airquality)
partialPlot(ozone.rf, airquality, Temp)
data(iris)
set.seed(543)
iris.rf <- RRF(Species~., iris)
partialPlot(iris.rf, iris, Petal.Width, "versicolor")