R/ResamplingForecastCV.R
mlr_resamplings_forecast_cv.Rd
Splits data using a folds
-folds (default: 10 folds) rolling window cross-validation.
This Resampling can be instantiated via the dictionary mlr_resamplings or with the associated sugar function rsmp()
:
$get("forecast_cv")
mlr_resamplingsrsmp("forecast_cv")
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.
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.
as_benchmark_result()
to convert to a BenchmarkResult.
Chapter in the mlr3book: https://mlr3book.mlr-org.com/performance.html#sec-resampling
Package mlr3viz for some generic visualizations.
Other resample:
mlr_resamplings_forecast_holdout
mlr3::Resampling
-> ResamplingForecastCV
iters
(integer(1)
)
Returns the number of resampling iterations, depending on the values stored in the param_set
.
# 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
#>
#>