Task: Task Class

Description Format Construction Fields Methods S3 methods Task mutators See Also Examples

Description

This is the abstract base class for task objects like TaskClassif and TaskRegr.

Tasks serve two purposes:

  1. Tasks wrap a DataBackend, an object to transparently interface different data storage types.

  2. Tasks store meta-information, such as the role of the individual columns in the DataBackend. For example, for a classification task a single column must be marked as target column, and others as features.

Predefined (toy) tasks are stored in the mlr3misc::Dictionary mlr_tasks, e.g. iris or boston_housing.

Format

R6::R6Class object.

Construction

Note: This object is typically constructed via a derived classes, e.g. TaskClassif or TaskRegr.

1
t = Task$new(id, task_type, backend)

Fields

Methods

S3 methods

Task mutators

The following methods change the task in-place:

See Also

Other Task: TaskClassif, TaskRegr, TaskSupervised, mlr_tasks

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# we use the inherited class TaskClassif here,
# Class Task is not intended for direct use
task = TaskClassif$new("iris", iris, target = "Species")

task$nrow
task$ncol
task$feature_names
task$formula()

# Remove "Petal.Length"
task$set_col_role("Petal.Length", character())

# Remove "Petal.Width", alternative way
task$select(setdiff(task$feature_names, "Petal.Width"))

task$feature_names

# Add new column "foo"
task$cbind(data.frame(foo = 1:150))
task$head()

mllg/mlr3 documentation built on Sept. 27, 2019, 9:38 a.m.