Skip to contents

Renders first-order Accumulated Local Effects as a ggplot2 figure. Continuous predictors are drawn as line plots and categorical predictors as bar charts, both faceted by variable name, the same arrangement as plot.gg_partial_rfsrc, so the two are directly comparable side by side.

Usage

# S3 method for class 'gg_ale_rfsrc'
plot(x, labels = NULL, ...)

Arguments

x

A gg_ale_rfsrc object.

labels

Optional variable labels for the facet strips. One of: a named character vector (c(bpd_last = "BP Diastole")); a labelled data frame, whose attr(col, "label") values are read; or a two-column key/label data frame. Variables with no label keep their raw name. Defaults to NULL (raw names).

...

Not currently used.

Value

A ggplot (or patchwork) object. When both continuous and categorical variables are present the two panels are combined vertically via patchwork::wrap_plots().

Examples

airq.obj <- randomForestSRC::rfsrc(Ozone ~ ., data = na.omit(airquality),
                                    ntree = 50)
ale_dta <- gg_ale_rfsrc(airq.obj, xvar.names = c("Wind", "Temp"),
                         n_eval = 10)
plot(ale_dta)