| make_future | R Documentation |
Convert forecasts from a fable object to a standardized forecast
table.
make_future(fable, context)
fable |
A |
context |
A named |
make_future() converts the output of forecast() into a
tibble with a consistent structure for downstream evaluation,
plotting, and accuracy calculation.
The returned future_frame contains one row per forecasted observation,
time series, split, and model. It includes the following columns:
the time index column specified by context$index_id;
the series identifier column specified by context$series_id;
model: the forecasting model name;
split: the train-test split identifier;
horizon: the forecast horizon within each series, split, and
model;
point: the point forecast, taken from the .mean column
of the fable.
This format is used by functions such as make_accuracy() and
make_errors().
A tibble containing forecasts in standardized future_frame
format.
Other time series cross-validation:
make_split(),
make_tsibble(),
slice_test(),
slice_train(),
split_index()
library(dplyr)
library(tsibble)
library(fable)
library(fabletools)
context <- list(
series_id = "series",
value_id = "value",
index_id = "index"
)
main_frame <- M4_monthly_data |>
filter(series %in% c("M23100", "M14395"))
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
) |>
as_tsibble(
index = index,
key = c(series, split)
)
model_frame <- train_frame |>
model(
"SNAIVE" = SNAIVE(value ~ lag("year"))
)
fable_frame <- model_frame |>
forecast(h = 18)
future_frame <- make_future(
fable = fable_frame,
context = context
)
future_frame
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.