This task specializes Task and TaskSupervised for classification problems. The target column is assumed to be a factor. The task_type is set to "classif".

• "twoclass": The task is a binary classification problem.

• "multiclass": The task is a multiclass classification problem.

## Construction

t = TaskClassif$new(id, backend, target, positive = NULL)  • id :: character(1) Identifier for the task. • backend :: DataBackend Either a DataBackend, or any object which is convertible to a DataBackend with as_data_backend(). E.g., a data.frame() will be converted to a DataBackendDataTable. • target :: character(1) Name of the target column. • positive :: character(1) Only for binary classification: Name of the positive class. The levels of the target columns are reordered accordingly, so that the first element of $class_names is the positive class, and the second element is the negative class.

## Fields

• class_names :: character()
Returns all class labels of the target column.

• positive :: character(1)
Stores the positive class for binary classification tasks, and NA for multiclass tasks. To switch the positive class, assign a level to this field.

• negative :: character(1)
Stores the negative class for binary classification tasks, and NA for multiclass tasks.

## Methods

Example classification tasks: iris

Other Task: TaskRegr, TaskSupervised, Task, mlr_tasks

## Examples

data("Sonar", package = "mlbench")
task = TaskClassif$new("sonar", backend = Sonar, target = "Class", positive = "M") task$task_type#> [1] "classif"task$formula()#> Class ~ . #> NULLtask$truth()#>   [1] R R M M M M M M M M M M R M M M M M M M M M M R M M M M M M M M M M R M M
#>  [38] M M M M M M M M R M M M M M M M M M M R M M M M M M M M M M R M M M M M M
#>  [75] M M M M R M M M M M M M M M M R M M M M M M M M M M R M M M M M M M M M M
#> [112] R R M M M M M M M M M R R R R R R R R R R R R R R R R R R R R R R R R R R
#> [149] R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R
#> [186] R R R R R R R R R R R R R R R R R R R R R M M
#> Levels: M Rtask$class_names#> [1] "M" "R"task$positive#> [1] "M"
# possible properties:
mlr_reflections$task_properties$classif#> [1] "strata"     "groups"     "weights"    "twoclass"   "multiclass"