Plotting of dice objects.
Arguments
- x
Object of class
diceto plot.- plot_margin
Extra margin to pass to
ylimas a fraction of the range ofx$d_ice_curves.- frac_to_plot
If
frac_to_plotis less than 1, randomly plotfrac_to_plotfraction of the curves inx$d_ice_curves.- plot_sd
If
TRUE, plot the cross-observation sd of partial derivatives below the derivative plots.- plot_orig_pts_deriv
If
TRUE, marks each curve at the location of the derivative estimate at the location ofpredictoractually occurring in the data. IfFALSEno mark is drawn.- pts_preds_size
Size of points to make if
plot_orig_pts_derivisTRUE.- colorvec
Optional vector of colors to use for each curve.
- color_by
Optional variable name (or column number) in
Xiceto color curves by. If thecolor_byvariable has 10 or fewer unique values, a discrete set of colors is used for each value and a legend is printed and returned. If there are more values, curves are colored from light to dark corresponding to low to high values of the variable specified bycolor_by.- x_quantile
If
TRUE, the plot is drawn with the x-axis taken to bequantile(gridpts). IfFALSE, the predictor's original scale is used.- plot_dpdp
If
TRUE, the estimated derivative of the PDP is plotted and highlighted in yellow.- rug_quantile
If not null, tick marks are drawn on the x-axis corresponding to the vector of quantiles specified by this parameter. Forced to
NULLwhenx_quantileis set toTRUE.- verbose
If
TRUE, prints the color legend to the console.- ...
Additional plotting arguments.
Value
A list with the following elements.
- plot_points_indices
Row numbers of
Xiceof those observations presented in the plot.- legend_text
If the
color_byargument was used, a legend describing the map between thecolor_bypredictor and curve colors.- plot
The ggplot object used for plotting.
Examples
if (FALSE) { # \dontrun{
require(ICEbox)
require(randomForest)
require(MASS) #has Boston Housing data, Pima
data(Boston) #Boston Housing data
X = Boston
y = X$medv
X$medv = NULL
## build a RF:
bhd_rf_mod = randomForest(X, y)
## Create an 'ice' object for the predictor "age":
bhd.ice = ice(object = bhd_rf_mod, X = X, y = y, predictor = "age", frac_to_build = .1)
# estimate derivatives, then plot.
bhd.dice = dice(bhd.ice)
plot(bhd.dice)
} # }