Skip to contents

This task specializes Task, TaskSupervised and TaskRegr for forecasting problems. The target column is assumed to be numeric. The task_type is set to "fcst".

It is recommended to use as_task_fcst() for construction. Predefined tasks are stored in the dictionary mlr_tasks.

See also

Other Task: mlr_tasks_airpassengers, mlr_tasks_electricity, mlr_tasks_livestock

Super classes

mlr3::Task -> mlr3::TaskSupervised -> mlr3::TaskRegr -> TaskFcst

Public fields

freq

(character(1))
The frequency of the time series.

Active bindings

properties

(character())
Set of task properties. Possible properties are are stored in mlr_reflections$task_properties. The following properties are currently standardized and understood by tasks in mlr3:

  • "strata": The task is resampled using one or more stratification variables (role "stratum").

  • "groups": The task comes with grouping/blocking information (role "group").

  • "weights": The task comes with observation weights (role "weight").

  • "ordered": The task has columns which define the row order (role "order").

  • "keys": The task has columns which define the time series "key").

Note that above listed properties are calculated from the $col_roles and may not be set explicitly.

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class. The function as_task_fcst() provides an alternative way to construct forecast tasks.

Usage

TaskFcst$new(
  id,
  backend,
  target,
  order,
  key = NULL,
  freq = NULL,
  label = NA_character_,
  extra_args = list()
)

Arguments

id

(character(1))
Identifier for the new instance.

backend

(DataBackend)
Either a DataBackend, or any object which is convertible to a DataBackend with as_data_backend(). E.g., a data.frame() will be converted to a DataBackendDataTable.

target

(character(1))
Name of the target column.

order

(character(1))
Name of the order column.

key

(character(1))
Name of the key column.

freq

(character(1))
Frequency of the time series. One of "daily", "weekly", "monthly", "quarterly", "yearly".

label

(character(1))
Label for the new instance.

extra_args

(named list())
Named list of constructor arguments, required for converting task types via convert_task().


Method print()

Printer.

Usage

TaskFcst$print(...)

Arguments

...

(ignored).


Method clone()

The objects of this class are cloneable with this method.

Usage

TaskFcst$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(data.table)
airpassengers = tsbox::ts_dt(AirPassengers)
setnames(airpassengers, c("date", "passengers"))
task = as_task_fcst(airpassengers, target = "passengers", order = "date")
task$task_type
#> [1] "fcst"
task$formula()
#> passengers ~ .
#> NULL
task$truth()
#>   [1] 112 118 132 129 121 135 148 148 136 119 104 118 115 126 141 135 125 149
#>  [19] 170 170 158 133 114 140 145 150 178 163 172 178 199 199 184 162 146 166
#>  [37] 171 180 193 181 183 218 230 242 209 191 172 194 196 196 236 235 229 243
#>  [55] 264 272 237 211 180 201 204 188 235 227 234 264 302 293 259 229 203 229
#>  [73] 242 233 267 269 270 315 364 347 312 274 237 278 284 277 317 313 318 374
#>  [91] 413 405 355 306 271 306 315 301 356 348 355 422 465 467 404 347 305 336
#> [109] 340 318 362 348 363 435 491 505 404 359 310 337 360 342 406 396 420 472
#> [127] 548 559 463 407 362 405 417 391 419 461 472 535 622 606 508 461 390 432