autoplot.ResamplingSpCVBlock {mlr3spatiotempcv} | R Documentation |
Visualization Functions for SpCV Block Methods.
Description
Generic S3 plot()
and autoplot()
(ggplot2) methods to
visualize mlr3 spatiotemporal resampling objects.
Usage
## S3 method for class 'ResamplingSpCVBlock'
autoplot(
object,
task,
fold_id = NULL,
plot_as_grid = TRUE,
train_color = "#0072B5",
test_color = "#E18727",
show_blocks = FALSE,
show_labels = FALSE,
sample_fold_n = NULL,
label_size = 2,
...
)
## S3 method for class 'ResamplingRepeatedSpCVBlock'
autoplot(
object,
task,
fold_id = NULL,
repeats_id = 1,
plot_as_grid = TRUE,
train_color = "#0072B5",
test_color = "#E18727",
show_blocks = FALSE,
show_labels = FALSE,
sample_fold_n = NULL,
label_size = 2,
...
)
## S3 method for class 'ResamplingSpCVBlock'
plot(x, ...)
## S3 method for class 'ResamplingRepeatedSpCVBlock'
plot(x, ...)
Arguments
object |
|
task |
|
fold_id |
|
plot_as_grid |
|
train_color |
|
test_color |
|
show_blocks |
|
show_labels |
|
sample_fold_n |
|
label_size |
|
... |
Passed to |
repeats_id |
|
x |
|
Details
By default a plot is returned; if fold_id
is set, a gridded plot is
created. If plot_as_grid = FALSE
, a list of plot objects is returned.
This can be used to align the plots individually.
When no single fold is selected, the ggsci::scale_color_ucscgb()
palette
is used to display all partitions.
If you want to change the colors, call <plot> + <color-palette>()
.
Value
ggplot()
or list of ggplot2 objects.
See Also
mlr3book chapter on "Spatial Analysis"
Examples
if (mlr3misc::require_namespaces(c("sf", "blockCV"), quietly = TRUE)) {
library(mlr3)
library(mlr3spatiotempcv)
task = tsk("ecuador")
resampling = rsmp("spcv_block", range = 1000L)
resampling$instantiate(task)
## list of ggplot2 resamplings
plot_list = autoplot(resampling, task,
crs = 4326,
fold_id = c(1, 2), plot_as_grid = FALSE)
## Visualize all partitions
autoplot(resampling, task) +
ggplot2::scale_x_continuous(breaks = seq(-79.085, -79.055, 0.01))
## Visualize the train/test split of a single fold
autoplot(resampling, task, fold_id = 1) +
ggplot2::scale_x_continuous(breaks = seq(-79.085, -79.055, 0.01))
## Visualize train/test splits of multiple folds
autoplot(resampling, task,
fold_id = c(1, 2),
show_blocks = TRUE) *
ggplot2::scale_x_continuous(breaks = seq(-79.085, -79.055, 0.01))
}