Skip to contents

The records coloured by fold, with leaking records (same coordinates or raster cell in another fold) marked by black crosses. Legend entries give the number and share of records in each fold.

Usage

plot_folds(x, base_size = 11, file = NULL, width = 2100, height = 1800)

Arguments

x

A result of fold_report().

base_size

Base font size.

file

Optional file(s) to save the plot to, e.g. "fig.pdf" or c("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).

Value

A ggplot object.

References

Stock, A., Gregr, E.J., Chan, K.M.A. (2023) Data leakage jeopardizes ecological applications of machine learning. Nature Ecology & Evolution 7, 1743-1745. doi:10.1038/s41559-023-02162-1

Examples

sim <- simulate_enm_data(seed = 1)
pts <- rbind(cbind(sim$presence, occ = 1), cbind(sim$absence, occ = 0))
f <- spatial_folds(pts, k = 4, block_size = 100, occ = pts$occ, seed = 1)
plot_folds(fold_report(pts, f, occ = pts$occ))