Convert object to a TaskFcst. This is a S3 generic. mlr3forecast ships with methods for the following objects:
TaskFcst: ensure the identity
data.frame()
and mlr3::DataBackend: provides an alternative to the constructor of TaskFcst.
Usage
as_task_fcst(x, ...)
# S3 method for class 'TaskFcst'
as_task_fcst(x, clone = FALSE, ...)
# S3 method for class 'DataBackend'
as_task_fcst(
x,
target = NULL,
order = character(),
key = character(),
freq = NULL,
id = deparse1(substitute(x)),
label = NA_character_,
...
)
# S3 method for class 'data.frame'
as_task_fcst(
x,
target = NULL,
order = character(),
key = character(),
freq = NULL,
id = deparse1(substitute(x)),
label = NA_character_,
...
)
# S3 method for class 'tsf'
as_task_fcst(x, label = NA_character_, id = deparse1(substitute(x)), ...)
# S3 method for class 'ts'
as_task_fcst(x, label = NA_character_, id = deparse1(substitute(x)), ...)
Arguments
- x
(any)
Object to convert.- ...
(any)
Additional arguments.- clone
(
logical(1)
)
IfTRUE
, ensures that the returned object is not the same as the inputx
.- 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)
|integer(1)
)
Frequency of the time series. Either a positive number or one of the following: *"minutely"
*"hourly"
*"daily"
*"weekly"
*"monthly"
*"quarterly"
*"yearly"
- 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.
Examples
library(data.table)
airpassengers = tsbox::ts_dt(AirPassengers)
setnames(airpassengers, c("month", "passengers"))
as_task_fcst(airpassengers, target = "passengers", order = "month", freq = "monthly")
#>
#> ── <TaskFcst> (144x2) ──────────────────────────────────────────────────────────
#> • Target: passengers
#> • Properties: ordered
#> • Features (1):
#> • dte (1): month
#> • Order by: month
#> * Frequency: monthly