Skip to contents

Generates h future rows from the task's skeleton (using generate_newdata()), optionally overlays user-supplied newdata onto those rows, and predicts with the trained learner via mlr3::Learner$predict_newdata(). Works with RecursiveForecaster, DirectForecaster, and classic LearnerFcst* forecasters.

Usage

# S3 method for class 'Learner'
forecast(object, task, h = 12L, newdata = NULL, ...)

Arguments

object

(mlr3::Learner)
A trained forecast learner.

task

(TaskFcst)
Provides the metadata needed to construct future rows: the order column (to extend the time index), key columns (for keyed tasks), freq, and the column-type schema expected by predict_newdata(). The task's data values are not used. Pass the training task or any other schema-compatible TaskFcst.

h

(integer(1))
Forecast horizon — number of future time steps per key.

newdata

(data.frame() | NULL)
Optional exogenous features for future rows. Must contain the order column (and any key columns for keyed tasks). Columns other than those are overlaid onto the generated skeleton.

...

(any)
Ignored.