mlr_resamplings_sptcv_cstf | R Documentation |
Splits data using Leave-Location-Out (LLO), Leave-Time-Out (LTO) and
Leave-Location-and-Time-Out (LLTO) partitioning.
See the upstream implementation at CreateSpacetimeFolds()
(package CAST) and Meyer et al. (2018) for further information.
LLO predicts on unknown locations i.e. complete locations are left out in the
training sets.
The "space"
role in Task$col_roles
identifies spatial units.
If stratify
is TRUE
, the target distribution is similar in each fold.
This is useful for land cover classification when the observations
are polygons.
In this case, LLO with stratification should be used to hold back complete
polygons and have a similar target distribution in each fold.
LTO leaves out complete temporal units which are identified by the
"time"
role in Task$col_roles
.
LLTO leaves out spatial and temporal units.
See the examples.
folds
(integer(1)
)
Number of folds.
stratify
If TRUE
, stratify on the target column.
mlr3::Resampling
-> ResamplingSptCVCstf
iters
integer(1)
Returns the number of resampling iterations, depending on the
values stored in the param_set
.
new()
Create a "Spacetime Folds" resampling instance.
ResamplingSptCVCstf$new(id = "sptcv_cstf")
id
character(1)
Identifier for the resampling strategy.
instantiate()
Materializes fixed training and test splits for a given task.
ResamplingSptCVCstf$instantiate(task)
task
Task
A task to instantiate.
clone()
The objects of this class are cloneable with this method.
ResamplingSptCVCstf$clone(deep = FALSE)
deep
Whether to make a deep clone.
Meyer H, Reudenbach C, Hengl T, Katurji M, Nauss T (2018). “Improving performance of spatio-temporal machine learning models using forward feature selection and target-oriented validation.” Environmental Modelling & Software, 101, 1–9. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.envsoft.2017.12.001")}.
library(mlr3)
task = tsk("cookfarm_mlr3")
task$set_col_roles("SOURCEID", roles = "space")
task$set_col_roles("Date", roles = "time")
# Instantiate Resampling
rcv = rsmp("sptcv_cstf", folds = 5)
rcv$instantiate(task)
### Individual sets:
# rcv$train_set(1)
# rcv$test_set(1)
# check that no obs are in both sets
intersect(rcv$train_set(1), rcv$test_set(1)) # good!
# Internal storage:
# rcv$instance # table
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.