- object
A fitted model object of appropriate class (e.g., "gbm",
"lm", "randomForest", "train", etc.).
- ...
Additional optional arguments to be passed onto
predict.
- pred.var
Character string giving the names of the predictor variables
of interest. For reasons of computation/interpretation, this should include
no more than three variables.
- pred.grid
Data frame containing the joint values of interest for the
variables listed in pred.var.
- pred.fun
Optional prediction function that requires two arguments:
object and newdata. If specified, then the function must return
a single prediction or a vector of predictions (i.e., not a matrix or data
frame). Default is NULL.
- grid.resolution
Integer giving the number of equally spaced points to
use for the continuous variables listed in pred.var when
pred.grid is not supplied. If left NULL, it will default to
the minimum between 51 and the number of unique data points for each
of the continuous independent variables listed in pred.var.
- ice
Logical indicating whether or not to compute individual
conditional expectation (ICE) curves. Default is FALSE. See
Goldstein et al. (2014) for details.
- center
Logical indicating whether or not to produce centered ICE
curves (c-ICE curves). Only used when ice = TRUE. Default is
FALSE. See Goldstein et al. (2014) for details.
- approx
Logical indicating whether or not to compute a faster, but
approximate, marginal effect plot (similar in spirit to the
plotmo package). If TRUE, then partial() will compute
predictions across the predictors specified in pred.var while holding
the other predictors constant (a "poor man's partial dependence" function as
Stephen Milborrow, the author of plotmo, puts it).
Default is FALSE. Note this works with ice = TRUE as well.
WARNING: This option is currently experimental. Use at your own risk. It is
possible (and arguably safer) to do this manually by passing a specific
"exemplar" observation to the train argument and specifying pred.grid
manually.
- quantiles
Logical indicating whether or not to use the sample
quantiles of the continuous predictors listed in pred.var. If
quantiles = TRUE and grid.resolution = NULL the sample
quantiles will be used to generate the grid of joint values for which the
partial dependence is computed.
- probs
Numeric vector of probabilities with values in [0,1]. (Values up
to 2e-14 outside that range are accepted and moved to the nearby endpoint.)
Default is 1:9/10 which corresponds to the deciles of the predictor
variables. These specify which quantiles to use for the continuous predictors
listed in pred.var when quantiles = TRUE.
- trim.outliers
Logical indicating whether or not to trim off outliers
from the continuous predictors listed in pred.var (using the simple
boxplot method) before generating the grid of joint values for which the
partial dependence is computed. Default is FALSE.
- type
Character string specifying the type of supervised learning.
Current options are "auto", "regression" or
"classification". If type = "auto" then partial will try
to extract the necessary information from object.
- inv.link
Function specifying the transformation to be applied to the
predictions before the partial dependence function is computed
(experimental). Default is NULL (i.e., no transformation). This option
is intended to be used for models that allow for non-Gaussian response
variables (e.g., counts). For these models, predictions are not typically
returned on the original response scale by default. For example, Poisson GBMs
typically return predictions on the log scale. In this case setting
inv.link = exp will return the partial dependence function on the
response (i.e., raw count) scale.
- which.class
Integer specifying which column of the matrix of predicted
probabilities to use as the "focus" class. Default is to use the first class.
Only used for classification problems (i.e., when
type = "classification").
- prob
Logical indicating whether or not partial dependence for
classification problems should be returned on the probability scale, rather
than the centered logit. If FALSE, the partial dependence function is
on a scale similar to the logit. Default is FALSE.
- recursive
Logical indicating whether or not to use the weighted tree
traversal method described in Friedman (2001). This only applies to objects
that inherit from class "gbm". Default is TRUE which is much
faster than the exact brute force approach used for all other models. (Based
on the C++ code behind plot.gbm.)
- plot
Logical indicating whether to return a data frame containing the
partial dependence values (FALSE) or plot the partial dependence
function directly (TRUE). Default is FALSE. See
plotPartial for plotting details.
- plot.engine
Character string specifying which plotting engine to use
whenever plot = TRUE. Options include "lattice" (default) or
"ggplot2".
- smooth
Logical indicating whether or not to overlay a LOESS smooth.
Default is FALSE.
- rug
Logical indicating whether or not to include a rug display on the
predictor axes. The tick marks indicate the min/max and deciles of the
predictor distributions. This helps reduce the risk of interpreting the
partial dependence plot outside the region of the data (i.e., extrapolating).
Only used when plot = TRUE. Default is FALSE.
- chull
Logical indicating whether or not to restrict the values of the
first two variables in pred.var to lie within the convex hull of their
training values; this affects pred.grid. This helps reduce the risk of
interpreting the partial dependence plot outside the region of the data
(i.e., extrapolating).Default is FALSE.
- levelplot
Logical indicating whether or not to use a false color level
plot (TRUE) or a 3-D surface (FALSE). Default is TRUE.
- contour
Logical indicating whether or not to add contour lines to the
level plot. Only used when levelplot = TRUE. Default is FALSE.
- contour.color
Character string specifying the color to use for the
contour lines when contour = TRUE. Default is "white".
- alpha
Numeric value in [0, 1] specifying the opacity alpha (
most useful when plotting ICE/c-ICE curves). Default is 1 (i.e., no
transparency). In fact, this option only affects ICE/c-ICE curves and level
plots.
- train
An optional data frame, matrix, or sparse matrix containing the
original training data. This may be required depending on the class of
object. For objects that do not store a copy of the original training
data, this argument is required. For reasons discussed below, it is good
practice to always specify this argument.
- cats
Character string indicating which columns of train should
be treated as categorical variables. Only used when train inherits
from class "matrix" or "dgCMatrix".
- check.class
Logical indicating whether or not to make sure each column
in pred.grid has the correct class, levels, etc. Default is
TRUE.
- progress
Logical indicating whether or not to display a text-based
progress bar. Default is FALSE.
- parallel
Logical indicating whether or not to run partial in
parallel using a backend provided by the foreach package. Default is
FALSE.
- paropts
List containing additional options to be passed onto
foreach when parallel = TRUE.