This is the abstract base class for task objects like TaskClassif and TaskRegr. It extends Task with methods to handle a target columns.

Format

R6::R6Class object inheriting from Task.

Construction

t = TaskSupervised$new(id, task_type, backend, target)

Methods

  • truth(row_ids = NULL) :: data.table::data.table()
    Table with true labels for specified row_ids. Defaults to all rows in use.

Fields

  • backend :: DataBackend.

  • col_info :: data.table::data.table()
    Table with with 3 columns: Column names of DataBackend are stored in columnid. Column type holds the storage type of the variables, e.g. integer, numeric or character. Column levels keeps a list of possible levels for factor and character variables.

  • col_roles :: named list()
    Each column (feature) can have an arbitrary number of roles in the learning task:

    • "target": Labels to predict.

    • "feature": Regular feature.

    • "order": Data returned by data() is ordered by this column (or these columns).

    • "group": During resampling, observations with the same value of the variable with role "group" are marked as "belonging together". They will be exclusively assigned to be either in the training set or the test set for each resampling iteration.

    • "weights": Observation weights. col_roles keeps track of the roles with a named list of vectors of feature names. To alter the roles, use t$set_col_role().

  • row_roles :: named list()
    Each row (observation) can have an arbitrary number of roles in the learning task:

    • "use": Use in train / predict / resampling.

    • "validation": Hold the observations back unless explicitly requested. row_roles keeps track of the roles with a named list of vectors of feature names. To alter the role, use set_row_role().

  • feature_names :: character()
    Returns all column names with role == "feature".

  • feature_types :: data.table::data.table()
    Returns a table with columns id and type where id are the column names of "active" features of the task and type is the storage type.

  • formula :: formula()
    Constructs a stats::formula, e.g. [target] ~ [feature_1] + [feature_2] + ... + [feature_k], using the active features of the task.

  • group :: data.table::data.table()
    Returns a table with columns row_id and group where row_id are the row ids and group is the value of the grouping variable. Returns NULL if there is no grouping.

  • hash :: character(1)
    Hash (unique identifier) for this object.

  • id :: character(1)
    Stores the identifier of the Task.

  • measures :: list() of Measure
    Stores the measures to use for this task.

  • ncol :: integer(1)
    Returns the total number of cols with role "target" or "feature".

  • nrow :: integer(1)
    Return the total number of rows with role "use".

  • row_ids :: (integer() | character())
    Returns the row ids of the DataBackend for observations with with role "use".

  • target_names :: character()
    Returns all column names with role "target".

  • task_type :: character(1)
    Stores the type of the Task.

See also

Examples

b = as_data_backend(iris) task = TaskSupervised$new("iris", task_type = "classif", backend = b, target = "Species")