Shows the models from select_models() in the space of two metrics.
Selected models are filled, Pareto-front models are circles (others are
squares), dashed lines mark the required minimum and maximum values, and
bars show, for each axis, the bootstrap interval (<metric>_lower,
<metric>_upper, e.g. from temporal_validation() or
evaluate_models() with n_boot) or else +/- 1 SD across runs
(<metric>_sd, from evaluate_cv()). Keep these columns when you build
the table for select_models(). Call
it several times for several panels, e.g. AUC vs MAE and AUC vs fossil AUC.
Usage
plot_selection(
x,
x_metric = NULL,
y_metric = NULL,
labels = TRUE,
zoom = FALSE,
error_bars = TRUE,
bar_colour = "#c8553d",
base_size = 12,
file = NULL,
width = 2100,
height = 1500
)
# S3 method for class 'enm_selection'
plot(
x,
y,
x_metric = NULL,
y_metric = NULL,
zoom = "auto",
...,
file = NULL,
width = 4200,
height = 1650
)Arguments
- x
An
enm_selectionobject fromselect_models().- x_metric, y_metric
Columns to plot on the x and y axes. Default: the second and the first selection criterion.
- labels
Label the points with model names.
- zoom
FALSE,TRUE(region of the best models) or a list of axis limits (see Details). Forplot():"auto"adds the zoomed plot when it leaves out at least one model.- error_bars
Draw the error bars (
TRUE/FALSE).- bar_colour
Colour of the error bars.
- base_size
Base font size.
- file
Optional file(s) to save the plot to, e.g.
"fig.pdf"orc("fig.png", "fig.pdf"); the format follows the extension, and a name without extension is saved as PNG and PDF. The plot is also returned.- width, height
Size of the saved figure in pixels (PDF and SVG at 300 pixels per inch).
- y
Ignored.
- ...
Passed to
plot_selection().
Value
A ggplot object; plot() returns a list with all and zoom
invisibly.
Details
Zoom. When many models are close together the plot gets cluttered.
zoom = TRUE shows only the region of the best models: the 2-D Pareto
fronts of the two plotted metrics are added one after another until at
least half of the models (and at least three) are included, and the view
is their range. Models outside the view are named in the subtitle. Give
your own limits with zoom = list(x = c(0.19, 0.24), y = c(0.89, 0.93)).
plot(sel) draws the full plot and, next to it, the zoom (when the zoom
leaves out at least one model), and returns both.
Selected models are drawn on top, so they are never hidden behind other
points. Pareto-front membership is computed on all criteria of
select_models(); with more than the two plotted criteria, a front model
can look dominated in the plot (noted in the subtitle). See
plot_models() for interactive and 3-D plots.
Examples
df <- data.frame(model = c("GLM", "GBM", "RF", "SRE"),
AUC = c(0.86, 0.88, 0.87, 0.71),
TSS = c(0.62, 0.65, 0.66, 0.38),
MAE = c(0.30, 0.27, 0.24, 0.41))
sel <- select_models(df)
plot_selection(sel)
plot_selection(sel, x_metric = "TSS")
plot_selection(sel, zoom = TRUE) # region of the best models
plot(sel) # full view and zoom side by side
