Temporal prediction / forecasting for mlr3

Time series analysis accounts for the fact that data points taken over time may have an internal structure (such as autocorrelation, trend or seasonal variation) that should be accounted for. This package extends the mlr3 package framework by time-series prediction and resampling methods.


Install the development version from GitHub:



Currently the following methods are implemented:


Id Code Type
airpassengers tsk("airpassengers") Univariate Timeseries
petrol tsk("petrol") Multivariate Timeseries


Id Learner Package
forecast.auto_arima Auto Arima forecast
forecast.arima Arima forecast
forecast.average Average base
forecast.VAR Vector Autoregression vars


Id Measure Package
forecast.mae Mean Absolute Error base
forecast.mape Mean Absolute Percentage Error base
forecast.mse Mean Squared Error base
forecast.rmse Root Mean Squared Error base

Resampling Methods

Id Resampling Package
forecast_holdout Holdout base
forecast_cv Rolling Window CrossValidation base

Code Example


task = tsk("airpassengers")
learner = lrn("forecast.auto_arima")
learner$train(task, row_ids = 1:20)
predictions = learner$predict(task, row_ids = 21:55)
measure = msr("forecast.mae")



Split data into a training set and a test set. Parameter ratio determines the ratio of observation going into the training set (default: 2/3).

task = tsk("petrol")
learner = lrn("forecast.VAR")
resampling = rsmp("forecast_holdout", ratio = 0.8)
rr = resample(task, learner, resampling, store_models = TRUE)

Rolling Window CV

Splits data using a folds-folds (default: 10 folds) rolling window cross-validation.

task = tsk("petrol")
learner = lrn("forecast.VAR")
resampling = rsmp("forecast_cv", folds = 5, fixed_window = FALSE)
rr = resample(task, learner, resampling, store_models = TRUE)

More resources

For detailed information on how to get started with mlr3 please read the mlr3 book and consult the Vignette for more examples of mlr3temporal.

Contributing to mlr3temporal

Please consult the wiki for a style guide, a roxygen guide and a pull request guide.