plot_pd | R Documentation |
This method creates partial dependence plots based on data in a familiarCollection object.
plot_pd(
object,
draw = FALSE,
dir_path = NULL,
split_by = NULL,
color_by = NULL,
facet_by = NULL,
facet_wrap_cols = NULL,
ggtheme = NULL,
discrete_palette = NULL,
gradient_palette = NULL,
gradient_palette_range = NULL,
x_label = waiver(),
y_label = waiver(),
legend_label = waiver(),
plot_title = waiver(),
plot_sub_title = waiver(),
caption = NULL,
x_range = NULL,
x_n_breaks = 5,
x_breaks = NULL,
y_range = NULL,
y_n_breaks = 5,
y_breaks = NULL,
novelty_range = NULL,
value_scales = waiver(),
novelty_scales = waiver(),
conf_int_style = c("ribbon", "step", "none"),
conf_int_alpha = 0.4,
show_novelty = TRUE,
anchor_values = NULL,
width = waiver(),
height = waiver(),
units = waiver(),
export_collection = FALSE,
...
)
## S4 method for signature 'ANY'
plot_pd(
object,
draw = FALSE,
dir_path = NULL,
split_by = NULL,
color_by = NULL,
facet_by = NULL,
facet_wrap_cols = NULL,
ggtheme = NULL,
discrete_palette = NULL,
gradient_palette = NULL,
gradient_palette_range = NULL,
x_label = waiver(),
y_label = waiver(),
legend_label = waiver(),
plot_title = waiver(),
plot_sub_title = waiver(),
caption = NULL,
x_range = NULL,
x_n_breaks = 5,
x_breaks = NULL,
y_range = NULL,
y_n_breaks = 5,
y_breaks = NULL,
novelty_range = NULL,
value_scales = waiver(),
novelty_scales = waiver(),
conf_int_style = c("ribbon", "step", "none"),
conf_int_alpha = 0.4,
show_novelty = TRUE,
anchor_values = NULL,
width = waiver(),
height = waiver(),
units = waiver(),
export_collection = FALSE,
...
)
object |
|
draw |
(optional) Draws the plot if TRUE. |
dir_path |
(optional) Path to the directory where created individual
conditional expectation plots are saved to. Output is saved in the
|
split_by |
(optional) Splitting variables. This refers to column names on which datasets are split. A separate figure is created for each split. See details for available variables. |
color_by |
(optional) Variables used to determine fill colour of plot
objects. The variables cannot overlap with those provided to the |
facet_by |
(optional) Variables used to determine how and if facets of
each figure appear. In case the |
facet_wrap_cols |
(optional) Number of columns to generate when facet wrapping. If NULL, a facet grid is produced instead. |
ggtheme |
(optional) |
discrete_palette |
(optional) Palette to use to colour the different
plot elements in case a value was provided to the |
gradient_palette |
(optional) Sequential or divergent palette used to colour the raster in 2D individual conditional expectation or partial dependence plots. This argument is not used for 1D plots. |
gradient_palette_range |
(optional) Numerical range used to span the
gradient for 2D plots. This should be a range of two values, e.g. |
x_label |
(optional) Label to provide to the x-axis. If NULL, no label is shown. |
y_label |
(optional) Label to provide to the y-axis. If NULL, no label is shown. |
legend_label |
(optional) Label to provide to the legend. If NULL, the legend will not have a name. |
plot_title |
(optional) Label to provide as figure title. If NULL, no title is shown. |
plot_sub_title |
(optional) Label to provide as figure subtitle. If NULL, no subtitle is shown. |
caption |
(optional) Label to provide as figure caption. If NULL, no caption is shown. |
x_range |
(optional) Value range for the x-axis. |
x_n_breaks |
(optional) Number of breaks to show on the x-axis of the
plot. |
x_breaks |
(optional) Break points on the x-axis of the plot. |
y_range |
(optional) Value range for the y-axis. |
y_n_breaks |
(optional) Number of breaks to show on the y-axis of the
plot. |
y_breaks |
(optional) Break points on the y-axis of the plot. |
novelty_range |
(optional) Numerical range used to span the range of
novelty values. This determines the size of the bubbles in 2D, and
transparency of lines in 1D. This should be a range of two values, e.g.
|
value_scales |
(optional) Sets scaling of predicted values. This parameter has several options:
For 1D plots, this option is ignored if the |
novelty_scales |
(optional) Sets scaling of novelty values, similar to
the
|
conf_int_style |
(optional) Confidence interval style. See details for allowed styles. |
conf_int_alpha |
(optional) Alpha value to determine transparency of confidence intervals or, alternatively, other plot elements with which the confidence interval overlaps. Only values between 0.0 (fully transparent) and 1.0 (fully opaque) are allowed. |
show_novelty |
(optional) Sets whether novelty is shown in plots. |
anchor_values |
(optional) A single value or a named list or array of
values that are used to centre the individual conditional expectation plot.
A single value is valid if and only if only a single feature is assessed.
Otherwise, values Has no effect if the plot is not shown, i.e.
|
width |
(optional) Width of the plot. A default value is derived from the number of facets. |
height |
(optional) Height of the plot. A default value is derived from the number of features and the number of facets. |
units |
(optional) Plot size unit. Either |
export_collection |
(optional) Exports the collection if TRUE. |
... |
Arguments passed on to
|
This function generates partial dependence plots. These plots come in two varieties, namely 1D and 2D. 1D plots show the predicted value as function of a single feature, whereas 2D plots show the predicted value as a function of two features.
Available splitting variables are: feature_x
, feature_y
(2D only),
fs_method
, learner
, data_set
and positive_class
(categorical
outcomes) or evaluation_time
(survival outcomes). By default, for 1D ICE
plots the data are split by feature_x
, fs_method
and learner
, with
faceting by data_set
, positive_class
or evaluation_time
. If only
partial dependence is shown, positive_class
and evaluation_time
are
used to set colours instead. For 2D plots, by default the data are split by
feature_x
, fs_method
and learner
, with faceting by data_set
,
positive_class
or evaluation_time
. The color_by
argument cannot be
used with 2D plots, and attempting to do so causes an error. Attempting to
specify feature_x
or feature_y
for color_by
will likewise result in
an error, as multiple features cannot be shown in the same facet.
The splitting variables indicated by color_by
are coloured according to
the discrete_palette
parameter. This parameter is therefore only used for
1D plots. Available palettes for discrete_palette
and gradient_palette
are those listed by grDevices::palette.pals()
(requires R >= 4.0.0),
grDevices::hcl.pals()
(requires R >= 3.6.0) and rainbow
, heat.colors
,
terrain.colors
, topo.colors
and cm.colors
, which correspond to the
palettes of the same name in grDevices
. If not specified, a default
palette based on palettes in Tableau are used. You may also specify your
own palette by using colour names listed by grDevices::colors()
or
through hexadecimal RGB strings.
Bootstrap confidence intervals of the partial dependence plots can be shown
using various styles set by conf_int_style
:
ribbon
(default): confidence intervals are shown as a ribbon with an
opacity of conf_int_alpha
around the point estimate of the partial
dependence.
step
(default): confidence intervals are shown as a step function around
the point estimate of the partial dependence.
none
: confidence intervals are not shown. The point estimate of the
partial dependence is shown as usual.
Labelling methods such as set_fs_method_names
or set_data_set_names
can
be applied to the familiarCollection
object to update labels, and order
the output in the figure.
NULL
or list of plot objects, if dir_path
is NULL
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.