`ice`

objects.Plotting of `ice`

objects.

```
# S3 method for ice
plot(x, plot_margin = 0.05, frac_to_plot = 1,
plot_points_indices = NULL, plot_orig_pts_preds = TRUE,
pts_preds_size = 1.5, colorvec, color_by = NULL,
x_quantile = FALSE, plot_pdp = TRUE,
centered = FALSE, prop_range_y = TRUE,
rug_quantile = seq(from = 0, to = 1, by = 0.1),
centered_percentile = 0,
point_labels = NULL, point_labels_size = NULL,
prop_type,...)
```

x

Object of class `ice`

to plot.

plot_margin

Extra margin to pass to `ylim`

as a fraction of the range of `x$ice_curves`

.

frac_to_plot

If `frac_to_plot`

is less than 1, randomly plot `frac_to_plot`

fraction of the
curves in `x$ice_curves`

.

plot_points_indices

If not `NULL`

, this plots only the indices of interest. If not `NULL`

, `frac_to_plot`

must be 1 otherwise
an error is thrown. Default is `NULL`

.

plot_orig_pts_preds

If `TRUE`

, marks each curve at the location of the observation's actual fitted value. If `FALSE`

,
no mark is drawn.

pts_preds_size

Size of points to make if `plot_origin_pts_preds`

is `TRUE`

.

colorvec

Optional vector of colors to use for each curve.

color_by

Optional variable name in `Xice`

, column number in `Xice`

, or data vector of the correct length to color curves by.
If the `color_by`

variable 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 by `color_by`

.

x_quantile

If `TRUE`

, the plot is drawn with the x-axis taken to be `quantile(gridpts)`

. If `FALSE`

,
the predictor's original scale is used.

plot_pdp

If `TRUE`

, the PDP is plotted and highlighted in yellow.

centered

If `TRUE`

, all curves are re-centered to be 0 at the quantile given by `centered_percentile`

.
See Goldstein et al (2013) for details and examples. If `FALSE`

, the original `ice_curves`

are plotted.

prop_range_y

When `TRUE`

and `centered=TRUE`

as well, the range of the right vertical axis displays the
centered values as a fraction of the sd of the fitted values on actual observations if `prop_type`

is missing or set to `"sd"`

. If `prop_type`

is set to `"range"`

, the right axis displays the
centered values as a fraction of the range of the fitted values over the actual observations.

centered_percentile

The percentile of `predictor`

for which all `ice_curves`

are "pinched together" and set to be 0.
Default is .01.

point_labels

If not `NULL`

, labels to plot next to each point. Default is `NULL`

.

point_labels_size

If not `NULL`

, size of labels to plot next to each point. Default is `NULL`

which means it's the size of `pts_preds_size`

.

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 `NULL`

when `x_quantile`

is set to `TRUE`

.

prop_type

Scaling factor for the right vertical axis in centered plots if `prop_range_y`

is `TRUE`

. Can be one of
`"sd"`

(default) or `"range"`

. Ignored if `centered`

and `prop_range_y`

are not both `TRUE`

.

…

Other arguments to be passed to the `plot`

function.

A list with the following elements.

Row numbers of `Xice`

of those observations presented in the plot.

If the `color_by`

argument was used,
a legend describing the map between the `color_by`

predictor
and curve colors.

ice

# NOT RUN { 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) ## plot plot(bhd.ice, x_quantile = TRUE, plot_pdp = TRUE, frac_to_plot = 1) ## centered plot plot(bhd.ice, x_quantile = TRUE, plot_pdp = TRUE, frac_to_plot = 1, centered = TRUE) ## color the curves by high and low values of 'rm'. # First create an indicator variable which is 1 if the number of # rooms is greater than the median: median_rm = median(X$rm) bhd.ice$Xice$I_rm = ifelse(bhd.ice$Xice$rm > median_rm, 1, 0) plot(bhd.ice, frac_to_plot = 1, centered = TRUE, prop_range_y = TRUE, x_quantile = T, plot_orig_pts_preds = T, color_by = "I_rm") bhd.ice = ice(object = bhd_rf_mod, X = X, y = y, predictor = "age", frac_to_build = 1) plot(bhd.ice, frac_to_plot = 1, centered = TRUE, prop_range_y = TRUE, x_quantile = T, plot_orig_pts_preds = T, color_by = y) # }