Plots the marginal effect of the selected variables by "integrating" out the other variables.
Arguments
- x
A
gbm.objectthat was fit using a call togbm.- i.var
Vector of indices or the names of the variables to plot. If using indices, the variables are indexed in the same order that they appear in the initial
gbmformula. Iflength(i.var)is between 1 and 3 thenplot.gbmproduces the plots. Otherwise,plot.gbmreturns only the grid of evaluation points and their average predictions- n.trees
Integer specifying the number of trees to use to generate the plot. Default is to use
x$n.trees(i.e., the entire ensemble).- continuous.resolution
Integer specifying the number of equally space points at which to evaluate continuous predictors.
- return.grid
Logical indicating whether or not to produce graphics
FALSEor only return the grid of evaluation points and their average predictionsTRUE. This is useful for customizing the graphics for special variable types, or for higher dimensional graphs.- type
Character string specifying the type of prediction to plot on the vertical axis. See
predict.gbmfor details.- level.plot
Logical indicating whether or not to use a false color level plot (
TRUE) or a 3-D surface (FALSE). Default isTRUE.- contour
Logical indicating whether or not to add contour lines to the level plot. Only used when
level.plot = TRUE. Default isFALSE.- number
Integer specifying the number of conditional intervals to use for the continuous panel variables. See
co.intervalsandequal.countfor further details.- overlap
The fraction of overlap of the conditioning variables. See
co.intervalsandequal.countfor further details.- col.regions
Color vector to be used if
level.plotisTRUE. Defaults to the Matplotlib 'viridis' color map when theviridispackage is installed, and otherwise uses a built-in palette.- ...
Additional optional arguments to be passed onto
plot.
Value
If return.grid = TRUE, a grid of evaluation points and their
average predictions. Otherwise, a plot is returned.
Details
plot.gbm produces low dimensional projections of the
gbm.object by integrating out the variables not included in
the i.var argument. The function selects a grid of points and uses
the weighted tree traversal method described in Friedman (2001) to do the
integration. Based on the variable types included in the projection,
plot.gbm selects an appropriate display choosing amongst line plots,
contour plots, and lattice plots. If the default
graphics are not sufficient the user may set return.grid = TRUE, store
the result of the function, and develop another graphic display more
appropriate to the particular example.
Note
More flexible plotting is available using the
partial and plotPartial functions.
References
J. H. Friedman (2001). "Greedy Function Approximation: A Gradient Boosting Machine," Annals of Statistics 29(4).
B. M. Greenwell (2017). "pdp: An R Package for Constructing Partial Dependence Plots," The R Journal 9(1), 421–436. https://journal.r-project.org/articles/RJ-2017-016/index.html.
See also
partial, plotPartial,
gbm, and gbm.object.