Skip to contents

Convert object to a TaskFcst. This is a S3 generic. mlr3forecast ships with methods for the following objects:

  1. TaskFcst: ensure the identity

  2. data.frame() and mlr3::DataBackend: provides an alternative to the constructor of TaskFcst.

  3. ts: from base R time series objects (univariate and multivariate).

  4. zoo and xts: from zoo/xts time series objects.

  5. timeSeries: from Rmetrics timeSeries objects.

  6. tsf: from tsf format data.

  7. tbl_ts: from tsibble objects.

Usage

as_task_fcst(x, ...)

as_tasks_fcst(x, ...)

# Default S3 method
as_tasks_fcst(x, ...)

# S3 method for class 'list'
as_tasks_fcst(x, ...)

# S3 method for class 'TaskFcst'
as_task_fcst(x, clone = FALSE, ...)

# S3 method for class 'DataBackend'
as_task_fcst(
  x,
  target,
  order,
  key = character(),
  freq = NULL,
  id = deparse1(substitute(x)),
  label = NA_character_,
  ...
)

# S3 method for class 'data.frame'
as_task_fcst(
  x,
  target,
  order,
  key = character(),
  freq = NULL,
  id = deparse1(substitute(x)),
  label = NA_character_,
  ...
)

# S3 method for class 'tsf'
as_task_fcst(x, id = deparse1(substitute(x)), label = NA_character_, ...)

# S3 method for class 'ts'
as_task_fcst(
  x,
  freq = NULL,
  id = deparse1(substitute(x)),
  label = NA_character_,
  ...
)

# S3 method for class 'zoo'
as_task_fcst(
  x,
  freq = NULL,
  id = deparse1(substitute(x)),
  label = NA_character_,
  ...
)

# S3 method for class 'timeSeries'
as_task_fcst(
  x,
  freq = NULL,
  id = deparse1(substitute(x)),
  label = NA_character_,
  ...
)

# S3 method for class 'tbl_ts'
as_task_fcst(
  x,
  target,
  freq = NULL,
  id = deparse1(substitute(x)),
  label = NA_character_,
  ...
)

Arguments

x

(any)
Object to convert.

...

(any)
Additional arguments.

clone

(logical(1))
If TRUE, ensures that the returned object is not the same as the input x.

target

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

order

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

key

(character())
Names of the columns whose combination identifies a series. Key columns must be character, integer, factor, or ordered columns.

freq

(character(1) | numeric(1) | NULL)
Frequency of the time series. A seq()-compatible string gives the calendar step of the time grid, e.g. "1 month", "day", "3 months", "1 hour", "week". A positive number gives the seasonal period (as in stats::ts()) for an integer or numeric order column; the grid step is then inferred from the data.

id

(character(1))
Id for the new task. Defaults to the (deparsed and substituted) name of the data argument.

label

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

Value

TaskFcst.

Examples

library(data.table)
airpassengers = tsbox::ts_dt(AirPassengers)
setnames(airpassengers, c("month", "passengers"))
as_task_fcst(airpassengers, target = "passengers", order = "month", freq = "month")
#> 
#> ── <TaskFcst> (144x1) ──────────────────────────────────────────────────────────
#> • Target: passengers
#> • Properties: ordered
#> • Order by: month
#> • Frequency: month