Skip to contents

This task specializes Task and TaskSupervised for forecast 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.

Value

numeric().

See also

Super classes

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

Public fields

index

(character(1))
Column name of the index variable.

freq

(character(1))
Frequency of the time series.

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,
  index,
  freq,
  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.

index

(character(1))
Column name of the index variable.

freq

(character(1))
Frequency of the time series.

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 truth()

True response for specified row_ids. Format depends on the task type. Defaults to all rows with role "use".

Usage

TaskFcst$truth(rows = NULL)

Arguments

rows

(positive integer())
Vector or row indices.


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

airpassengers = tsbox::ts_dt(AirPassengers)
task = as_task_fcst(airpassengers, target = "value", index = "time", freq = "month")
task$task_type
#> [1] "fcst"
task$formula()
#> value ~ .
#> 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
task$data(rows = 1:3)
#>    value
#>    <num>
#> 1:   112
#> 2:   118
#> 3:   132