mlr3 (version 0.1.0)

TaskClassif: Classification Task

Description

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".

Predefined tasks are stored in the Dictionary mlr_tasks.

Arguments

Format

R6::R6Class object inheriting from Task/TaskSupervised.

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.

Fields

All methods from TaskSupervised, and additionally:

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

  • class_n :: integer(1) Returns the number of classes.

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

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

Methods

See TaskSupervised.

See Also

Example classification task: iris.

Other Task: TaskRegr, TaskSupervised, Task, mlr_generators, mlr_tasks

Examples

Run this code
# NOT RUN {
data("Sonar", package = "mlbench")
task = TaskClassif$new("sonar", backend = Sonar, target = "Class", positive = "M")

task$task_type
task$formula()
task$truth()
task$class_names
task$positive
task$negative

# possible properties:
mlr_reflections$task_properties$classif
# }

Run the code above in your browser using DataCamp Workspace