Skip to contents

Creates a TaskTorch, the general-purpose task type of mlr3torch, from a data.frame() or a DataBackend. See the Custom Learning Problems article for more information.

Usage

as_task_torch(x, target = NULL, id = deparse(substitute(x))[1L], ...)

Arguments

x

(data.frame() or DataBackend)
The data.

target

(character() or NULL)
The names of the target columns. NULL (default) for a task without a target, see section Tasks without a Target of TaskTorch.

id

(character(1))
The id of the task.

...

(any)
Further arguments passed to TaskTorch$new(), such as output_dim, default_encoder or default_measure.

Value

TaskTorch

Examples

# multi-output regression
d = data.frame(x = rnorm(50))
d$y1 = d$x + rnorm(50)
d$y2 = 2 * d$x + rnorm(50)
as_task_torch(d, target = c("y1", "y2"))
#> 
#> ── <TaskTorch> (50x3) ──────────────────────────────────────────────────────────
#> • Target: y1 and y2
#> • Properties: -
#> • Features (1):
#>   • dbl (1): x

# unsupervised: no target at all
as_task_torch(data.frame(a = rnorm(50), b = rnorm(50)))
#> 
#> ── <TaskTorch> (50x2) ──────────────────────────────────────────────────────────
#> • Target:
#> • Properties: -
#> • Features (2):
#>   • dbl (2): a, b