Creates a RecursiveForecaster (recursive strategy) or DirectForecaster (direct strategy),
selected via strategy.
Arguments
- learner
(mlr3::Learner | mlr3pipelines::Graph | mlr3pipelines::PipeOp)
A regression learner (whenlagsis provided) or a graph/PipeOp.- lags
(
integer()|NULL)
The lag values to use for creating lag features.- strategy
(
character(1))
Forecasting strategy. One of"recursive"(default) or"direct".- horizons
(
integer()|NULL)
Required whenstrategy = "direct"; must beNULLwhenstrategy = "recursive". A single integerHis expanded to1:H.- ...
(any)
Additional arguments passed to RecursiveForecaster or DirectForecaster.
Examples
library(mlr3pipelines)
# recursive forecasting (default)
flrn = as_learner_fcst(lrn("regr.rpart"), lags = 1:3)
# recursive with a custom graph
graph = po("fcst.lags", lags = 1:3) %>>% lrn("regr.rpart")
flrn = as_learner_fcst(graph)
# direct forecasting (one model per horizon)
flrn = as_learner_fcst(lrn("regr.rpart"), lags = 1:3, strategy = "direct", horizons = 12)