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.

See also

Other Task: mlr_tasks_airpassengers

Super classes

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

Public fields

key

(character(1))
Key of data.

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,
  key = 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.

key

(character(1)) key of data.

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 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)
data.table::setnames(airpassengers, c("date", "passengers"))
task = as_task_fcst(airpassengers, target = "passengers", index = "date")
task$task_type
#> [1] "regr"
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
task$data(rows = 1:3)
#>    passengers       date
#>         <num>     <Date>
#> 1:        112 1949-01-01
#> 2:        118 1949-02-01
#> 3:        132 1949-03-01