Learn R Programming

mlr3spatiotempcv (version 1.0.0)

ResamplingRepeatedSptCVCstf: (CAST) Repeated "leave-location-and-time-out" resampling

Description

Create spatial, temporal or spatio-temporal Folds for cross validation

Arguments

mlr3spatiotempcv notes

The 'Description', 'Details' and 'Note' fields are inherited from the respective upstream function.

For a list of available arguments, please see CAST::CreateSpacetimeFolds.

Super class

mlr3::Resampling -> ResamplingRepeatedSptCVCstf

Active bindings

iters

integer(1) Returns the number of resampling iterations, depending on the values stored in the param_set.

Methods

Public methods

Method new()

Create a "Spacetime Folds" resampling instance.

For a list of available arguments, please see CAST::CreateSpacetimeFolds.

Usage

ResamplingRepeatedSptCVCstf$new(id = "repeated_sptcv_cstf")

Arguments

id

character(1) Identifier for the resampling strategy.

Method folds()

Translates iteration numbers to fold number.

Usage

ResamplingRepeatedSptCVCstf$folds(iters)

Arguments

iters

integer() Iteration number.

Method repeats()

Translates iteration numbers to repetition number.

Usage

ResamplingRepeatedSptCVCstf$repeats(iters)

Arguments

iters

integer() Iteration number.

Method instantiate()

Materializes fixed training and test splits for a given task.

Usage

ResamplingRepeatedSptCVCstf$instantiate(task)

Arguments

task

Task A task to instantiate.

Method clone()

The objects of this class are cloneable with this method.

Usage

ResamplingRepeatedSptCVCstf$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

Using "class" is helpful in the case that data are clustered in space and are categorical. E.g This is the case for land cover classifications when training data come as training polygons. In this case the data should be split in a way that entire polygons are held back (spacevar="polygonID") but at the same time the distribution of classes should be similar in each fold (class="LUC").

References

Zhao Y, Karypis G (2002). “Evaluation of Hierarchical Clustering Algorithms for Document Datasets.” 11th Conference of Information and Knowledge Management (CIKM), 51-524. http://glaros.dtc.umn.edu/gkhome/node/167.

Examples

Run this code
# NOT RUN {
library(mlr3)
library(mlr3spatiotempcv)
task = tsk("cookfarm")

# Instantiate Resampling
rrcv = rsmp("repeated_sptcv_cstf", folds = 3, repeats = 5, time_var = "Date")
rrcv$instantiate(task)
# Individual sets:
rrcv$iters
rrcv$folds(1:6)
rrcv$repeats(1:6)

# Individual sets:
rrcv$train_set(1)
rrcv$test_set(1)
intersect(rrcv$train_set(1), rrcv$test_set(1))

# Internal storage:
rrcv$instance # table
# }

Run the code above in your browser using DataLab