Convert object to a TaskRegr. This is a S3 generic. mlr3 ships with methods for the following objects:
TaskRegr: ensure the identity
formula
,data.frame()
,matrix()
,Matrix::Matrix()
and DataBackend: provides an alternative to the constructor of TaskRegr.TaskClassif: Calls
convert_task()
.
Usage
as_task_regr(x, ...)
# S3 method for class 'TaskRegr'
as_task_regr(x, clone = FALSE, ...)
# S3 method for class 'data.frame'
as_task_regr(
x,
target = NULL,
id = deparse1(substitute(x)),
label = NA_character_,
...
)
# S3 method for class 'matrix'
as_task_regr(
x,
target = NULL,
id = deparse1(substitute(x)),
label = NA_character_,
...
)
# S3 method for class 'Matrix'
as_task_regr(
x,
target = NULL,
id = deparse1(substitute(x)),
label = NA_character_,
...
)
# S3 method for class 'DataBackend'
as_task_regr(
x,
target = NULL,
id = deparse1(substitute(x)),
label = NA_character_,
...
)
# S3 method for class 'TaskClassif'
as_task_regr(
x,
target = NULL,
drop_original_target = FALSE,
drop_levels = TRUE,
...
)
# S3 method for class 'formula'
as_task_regr(
x,
data,
id = deparse1(substitute(data)),
label = NA_character_,
...
)
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.- 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.- drop_original_target
(
logical(1)
)
IfFALSE
(default), the original target is added as a feature. Otherwise the original target is dropped.- drop_levels
(
logical(1)
)
IfTRUE
(default), unused levels of the new target variable are dropped.- data
(
data.frame()
)
Data frame containing all columns referenced in formulax
.
Examples
as_task_regr(datasets::mtcars, target = "mpg")
#> <TaskRegr:datasets::mtcars> (32 x 11)
#> * Target: mpg
#> * Properties: -
#> * Features (10):
#> - dbl (10): am, carb, cyl, disp, drat, gear, hp, qsec, vs, wt