autoplot.ResamplingSpCVKnndm {mlr3spatiotempcv} | R Documentation |
Visualization Functions for SpCV knndm Method.
Description
Generic S3 plot()
and autoplot()
(ggplot2) methods to
visualize mlr3 spatiotemporal resampling objects.
Usage
## S3 method for class 'ResamplingSpCVKnndm'
autoplot(
object,
task,
fold_id = NULL,
plot_as_grid = TRUE,
train_color = "#0072B5",
test_color = "#E18727",
repeats_id = NULL,
sample_fold_n = NULL,
...
)
## S3 method for class 'ResamplingRepeatedSpCVKnndm'
autoplot(
object,
task,
fold_id = NULL,
repeats_id = 1,
plot_as_grid = TRUE,
train_color = "#0072B5",
test_color = "#E18727",
sample_fold_n = NULL,
...
)
## S3 method for class 'ResamplingSpCVKnndm'
plot(x, ...)
## S3 method for class 'ResamplingRepeatedSpCVKnndm'
plot(x, ...)
Arguments
object |
|
task |
|
fold_id |
|
plot_as_grid |
|
train_color |
|
test_color |
|
repeats_id |
|
sample_fold_n |
|
... |
Passed to |
x |
|
Details
This method requires to set argument fold_id
and no plot containing all
partitions can be created. This is because the method does not make use of
all observations but only a subset of them (many observations are left out).
Hence, train and test sets of one fold are not re-used in other folds as in
other methods and plotting these without a train/test indicator would not
make sense.
2D vs 3D plotting
This method has both a 2D and a 3D plotting method.
The 2D method returns a ggplot with x and y axes representing the spatial
coordinates.
The 3D method uses plotly to create an interactive 3D plot.
Set plot3D = TRUE
to use the 3D method.
Note that spatiotemporal datasets usually suffer from overplotting in 2D mode.
See Also
mlr3book chapter on "Spatial Analysis"
Vignette Spatiotemporal Visualization.
Examples
if (mlr3misc::require_namespaces(c("CAST", "sf"), quietly = TRUE)) {
library(mlr3)
library(mlr3spatiotempcv)
task = tsk("ecuador")
points = sf::st_as_sf(task$coordinates(), crs = task$crs, coords = c("x", "y"))
modeldomain = sf::st_as_sfc(sf::st_bbox(points))
resampling = rsmp("spcv_knndm",
folds = 5, modeldomain = modeldomain)
resampling$instantiate(task)
autoplot(resampling, task,
fold_id = 1, size = 0.7) *
ggplot2::scale_x_continuous(breaks = seq(-79.085, -79.055, 0.01))
}