| slice_train | R Documentation |
Extract training observations from a complete time series data set according
to a split plan created by make_split().
slice_train(main_frame, split_frame, context)
main_frame |
A |
split_frame |
A |
context |
A named |
slice_train() uses the row positions stored in the train
list-column of split_frame to extract the corresponding observations
from main_frame. The function is designed for rolling-origin time
series cross-validation workflows.
The returned data has the same columns as main_frame, plus a
split column identifying the train-test split. If main_frame
contains multiple time series, slicing is performed separately for each
series using the series identifier supplied in context.
A tibble containing the sliced training data. It contains the same
columns as main_frame, plus a split column.
Other time series cross-validation:
make_future(),
make_split(),
make_tsibble(),
slice_test(),
split_index()
library(dplyr)
context <- list(
series_id = "series",
value_id = "value",
index_id = "index"
)
main_frame <- M4_monthly_data |>
filter(series == "M23100")
split_frame <- make_split(
main_frame = main_frame,
context = context,
type = "first",
value = 120,
n_ahead = 18,
n_skip = 17,
n_lag = 0,
mode = "stretch",
exceed = FALSE
)
train_frame <- slice_train(
main_frame = main_frame,
split_frame = split_frame,
context = context
)
train_frame
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.