This task specializes Task and TaskSupervised for regression problems.
The target column is assumed to be numeric.
The task_type is set to "regr".
It is recommended to use as_task_regr() for construction.
Predefined tasks are stored in the dictionary mlr_tasks.
See also
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html
Package mlr3data for more toy tasks.
Package mlr3oml for downloading tasks from https://www.openml.org.
Package mlr3viz for some generic visualizations.
Dictionary of Tasks: mlr_tasks
as.data.table(mlr_tasks)for a table of available Tasks in the running session (depending on the loaded packages).mlr3fselect and mlr3filters for feature selection and feature filtering.
Extension packages for additional task types:
Unsupervised clustering: mlr3cluster
Probabilistic supervised regression and survival analysis: https://mlr3proba.mlr-org.com/.
Other Task:
Task,
TaskClassif,
TaskSupervised,
TaskUnsupervised,
california_housing,
mlr_tasks,
mlr_tasks_breast_cancer,
mlr_tasks_german_credit,
mlr_tasks_iris,
mlr_tasks_mtcars,
mlr_tasks_penguins,
mlr_tasks_pima,
mlr_tasks_sonar,
mlr_tasks_spam,
mlr_tasks_wine,
mlr_tasks_zoo
Super classes
mlr3::Task -> mlr3::TaskSupervised -> TaskRegr
Methods
Inherited methods
mlr3::Task$add_strata()mlr3::Task$cbind()mlr3::Task$data()mlr3::Task$divide()mlr3::Task$droplevels()mlr3::Task$filter()mlr3::Task$format()mlr3::Task$formula()mlr3::Task$head()mlr3::Task$help()mlr3::Task$levels()mlr3::Task$materialize_view()mlr3::Task$missings()mlr3::Task$print()mlr3::Task$rbind()mlr3::Task$rename()mlr3::Task$select()mlr3::Task$set_col_roles()mlr3::Task$set_levels()mlr3::Task$set_row_roles()
Method new()
Creates a new instance of this R6 class.
The function as_task_regr() provides an alternative way to construct regression tasks.
Arguments
id(
character(1))
Identifier for the new instance.backend(DataBackend)
Either a DataBackend, or any object which is convertible to a DataBackend withas_data_backend(). E.g., adata.frame()will be converted to a DataBackendDataTable.target(
character(1))
Name of the target column.label(
character(1))
Label for the new instance.extra_args(named
list())
Named list of constructor arguments, required for converting task types viaconvert_task().
Method truth()
True response for specified row_ids. Format depends on the task type.
Defaults to all rows with role "use".
Arguments
rows(positive
integer())
Vector or row indices. Always refers to the complete data set, even after filtering.
Examples
task = as_task_regr(palmerpenguins::penguins, target = "bill_length_mm")
task$task_type
#> [1] "regr"
task$formula()
#> bill_length_mm ~ .
#> NULL
task$truth()
#> [1] 39.1 39.5 40.3 NA 36.7 39.3 38.9 39.2 34.1 42.0 37.8 37.8 41.1 38.6 34.6
#> [16] 36.6 38.7 42.5 34.4 46.0 37.8 37.7 35.9 38.2 38.8 35.3 40.6 40.5 37.9 40.5
#> [31] 39.5 37.2 39.5 40.9 36.4 39.2 38.8 42.2 37.6 39.8 36.5 40.8 36.0 44.1 37.0
#> [46] 39.6 41.1 37.5 36.0 42.3 39.6 40.1 35.0 42.0 34.5 41.4 39.0 40.6 36.5 37.6
#> [61] 35.7 41.3 37.6 41.1 36.4 41.6 35.5 41.1 35.9 41.8 33.5 39.7 39.6 45.8 35.5
#> [76] 42.8 40.9 37.2 36.2 42.1 34.6 42.9 36.7 35.1 37.3 41.3 36.3 36.9 38.3 38.9
#> [91] 35.7 41.1 34.0 39.6 36.2 40.8 38.1 40.3 33.1 43.2 35.0 41.0 37.7 37.8 37.9
#> [106] 39.7 38.6 38.2 38.1 43.2 38.1 45.6 39.7 42.2 39.6 42.7 38.6 37.3 35.7 41.1
#> [121] 36.2 37.7 40.2 41.4 35.2 40.6 38.8 41.5 39.0 44.1 38.5 43.1 36.8 37.5 38.1
#> [136] 41.1 35.6 40.2 37.0 39.7 40.2 40.6 32.1 40.7 37.3 39.0 39.2 36.6 36.0 37.8
#> [151] 36.0 41.5 46.1 50.0 48.7 50.0 47.6 46.5 45.4 46.7 43.3 46.8 40.9 49.0 45.5
#> [166] 48.4 45.8 49.3 42.0 49.2 46.2 48.7 50.2 45.1 46.5 46.3 42.9 46.1 44.5 47.8
#> [181] 48.2 50.0 47.3 42.8 45.1 59.6 49.1 48.4 42.6 44.4 44.0 48.7 42.7 49.6 45.3
#> [196] 49.6 50.5 43.6 45.5 50.5 44.9 45.2 46.6 48.5 45.1 50.1 46.5 45.0 43.8 45.5
#> [211] 43.2 50.4 45.3 46.2 45.7 54.3 45.8 49.8 46.2 49.5 43.5 50.7 47.7 46.4 48.2
#> [226] 46.5 46.4 48.6 47.5 51.1 45.2 45.2 49.1 52.5 47.4 50.0 44.9 50.8 43.4 51.3
#> [241] 47.5 52.1 47.5 52.2 45.5 49.5 44.5 50.8 49.4 46.9 48.4 51.1 48.5 55.9 47.2
#> [256] 49.1 47.3 46.8 41.7 53.4 43.3 48.1 50.5 49.8 43.5 51.5 46.2 55.1 44.5 48.8
#> [271] 47.2 NA 46.8 50.4 45.2 49.9 46.5 50.0 51.3 45.4 52.7 45.2 46.1 51.3 46.0
#> [286] 51.3 46.6 51.7 47.0 52.0 45.9 50.5 50.3 58.0 46.4 49.2 42.4 48.5 43.2 50.6
#> [301] 46.7 52.0 50.5 49.5 46.4 52.8 40.9 54.2 42.5 51.0 49.7 47.5 47.6 52.0 46.9
#> [316] 53.5 49.0 46.2 50.9 45.5 50.9 50.8 50.1 49.0 51.5 49.8 48.1 51.4 45.7 50.7
#> [331] 42.5 52.2 45.2 49.3 50.2 45.6 51.9 46.8 45.7 55.8 43.5 49.6 50.8 50.2
task$data(rows = 1:3, cols = task$feature_names[1:2])
#> bill_depth_mm body_mass_g
#> <num> <int>
#> 1: 18.7 3750
#> 2: 17.4 3800
#> 3: 18.0 3250