Forecast Cross-Validation Resampling
mlr_resamplings_forecast_cv.Rd
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():
Parameters
horizon
(integer(1)
)
Forecasting horizon in the test sets, i.e. number of test samples for each fold.folds
(integer(1)
)
Number of folds.step_size
(integer(1)
)
Step size between windows.window_size
(integer(1)
)
(Minimal) Size of the rolling window.fixed_window
(logial(1)
)
Should a fixed sized window be used? IfFALSE
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
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter3/evaluation_and_benchmarking.html#sec-resampling
Package mlr3spatiotempcv for spatio-temporal resamplings.
as.data.table(mlr_resamplings)
for a table of available Resamplings in the running session (depending on the loaded packages).mlr3spatiotempcv for additional Resamplings for spatio-temporal tasks.
Other Resampling:
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 theparam_set
.
Examples
# Create a task with 10 observations
task = tsk("airpassengers")
task$filter(1:20)
# Instantiate Resampling
cv = rsmp("forecast_cv", folds = 3, fixed_window = FALSE)
cv$instantiate(task)
# Individual sets:
cv$train_set(1)
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
cv$test_set(1)
#> [1] 20
intersect(cv$train_set(1), cv$test_set(1))
#> integer(0)
# Internal storage:
cv$instance # list
#> $train
#> $train[[1]]
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#>
#> $train[[2]]
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#>
#> $train[[3]]
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#>
#>
#> $test
#> $test[[1]]
#> [1] 20
#>
#> $test[[2]]
#> [1] 19
#>
#> $test[[3]]
#> [1] 18
#>
#>