Splits data using a folds-folds (default: 10 folds) rolling window cross-validation.

Dictionary

This Resampling can be instantiated via the dictionary mlr_resamplings or with the associated sugar function rsmp():

mlr_resamplings$get("forecast_cv")
rsmp("forecast_cv")

Parameters

  • folds (integer(1))
    Number of folds.

  • window_size (integer(1))
    (Minimal) Size of the rolling window.

  • horizon (integer(1))
    Forecasting horizon in the test sets.

  • fixed_window (logial(1))
    Flag for fixed sized window. If FALSE an expanding window is used.

References

Bergmeir, Christoph, Hyndman, J R, Koo, Bonsoo (2018). “A note on the validity of cross-validation for evaluating autoregressive time series prediction.” Computational Statistics & Data Analysis, 120, 70--83.

See also

Other resample: mlr_resamplings_forecast_holdout

Super class

mlr3::Resampling -> ResamplingForecastCV

Active bindings

iters

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

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

ResamplingForecastCV$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Create a task with 10 observations
task = mlr3::tsk("airpassengers")
task$filter(1:20)

# Instantiate Resampling
rfho = mlr3::rsmp("forecast_cv", folds = 3, fixed_window = FALSE)
rfho$instantiate(task)

# Individual sets:
rfho$train_set(1)
#>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13
rfho$test_set(1)
#> [1] 14 15 16 17 18
intersect(rfho$train_set(1), rfho$test_set(1))
#> integer(0)

# Internal storage:
rfho$instance #  list
#> $train
#> $train[[1]]
#>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13
#> 
#> $train[[2]]
#>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14
#> 
#> $train[[3]]
#>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
#> 
#> 
#> $test
#> $test[[1]]
#> [1] 14 15 16 17 18
#> 
#> $test[[2]]
#> [1] 15 16 17 18 19
#> 
#> $test[[3]]
#> [1] 16 17 18 19 20
#> 
#>