forecastML (version 0.5.0)

create_windows: Create time-contiguous validation datasets for model evaluation

Description

Flexibly ceate blocks of time-contiguous validation datasets to assess 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.

Usage

create_windows(lagged_df, window_length = 12L, window_start = NULL,
  window_stop = NULL, skip = 0, include_partial_window = TRUE)

Arguments

lagged_df

An object of class 'lagged_df' or 'grouped_lagged_df' from create_lagged_df.

window_length

An integer that defines the length of the contiguous validation dataset in dataset rows/dates. If dates were given in create_lagged_df(), the validation window is 'window_length' * 'date frequency' in calendar time. Setting window_length = 0 trains the model on the entire dataset--used for re-training after examining the cross-validation results.

window_start

Optional. An index or date identifying the row/date to start creating contiguous validation datasets.

window_stop

Optional. An index or date identifying the row to stop creating contiguous validation datasets.

skip

An integer giving a fixed number of dataset rows/time to skip between validation datasets. If dates were given in create_lagged_df, the time between validation windows is skip * 'date frequency'.

include_partial_window

Boolean. If TRUE, keep validation datasets that are shorter than window_length.

Value

An S3 object of class 'windows': A data.frame giving the indices for the validation datasets.

Methods and related functions

The output of create_windows() is passed into

and has the following generic S3 methods

Examples

Run this code
# NOT RUN {
# Sampled Seatbelts data from the R package datasets.
data("data_seatbelts", package = "forecastML")

# Example - Training data for 12 horizon-specific models w/ common lags per predictor.
horizons <- 1:12
lookback <- 1:15

data_train <- create_lagged_df(data_seatbelts, type = "train", outcome_col = 1,
                               lookback = lookback, horizon = horizons)

create_windows(data_train, window_length = 12)
# }

Run the code above in your browser using DataLab