Description Usage Arguments Value Methods and related functions Examples
View source: R/create_windows.R
Flexibly create blocks of time-contiguous validation datasets to assess the forecast accuracy of trained models at various times in the past. These validation datasets are similar to the outer loop of a nested cross-validation model training setup.
1 2 3 4 5 6 7 8 | create_windows(
lagged_df,
window_length = 12L,
window_start = NULL,
window_stop = NULL,
skip = 0,
include_partial_window = TRUE
)
|
lagged_df |
An object of class 'lagged_df' or 'grouped_lagged_df' from |
window_length |
An integer that defines the length of the contiguous validation dataset in dataset rows/dates.
If dates were given in |
window_start |
Optional. A row index or date identifying the row/date to start creating contiguous validation datasets. A
vector of start rows/dates can be supplied for greater control. The length and order of |
window_stop |
Optional. An index or date identifying the row/date to stop creating contiguous validation datasets. A
vector of start rows/dates can be supplied for greater control. The length and order of |
skip |
An integer giving a fixed number of dataset rows/dates to skip between validation datasets. If dates were given
in |
include_partial_window |
Boolean. If |
An S3 object of class 'windows': A data.frame giving the indices for the validation datasets.
The output of create_windows()
is passed into
train_model
and has the following generic S3 methods
plot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Sampled Seatbelts data from the R package datasets.
data("data_seatbelts", package = "forecastML")
# Example - Training data for 2 horizon-specific models w/ common lags per feature.
horizons <- c(1, 12)
lookback <- 1:15
data_train <- create_lagged_df(data_seatbelts, type = "train", outcome_col = 1,
lookback = lookback, horizon = horizons)
# All historical window lengths of 12 plus any partial windows at the end of the dataset.
windows <- create_windows(data_train, window_length = 12)
windows
# Two custom validation windows with different lengths.
windows <- create_windows(data_train, window_start = c(20, 80), window_stop = c(30, 100))
windows
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.