Convert object to a TaskClassif. This is a S3 generic, specialized for at least the following objects:

  1. TaskClassif: ensure the identity

  2. data.frame() and DataBackend: provides an alternative to the constructor of TaskClassif.

  3. TaskRegr: Calls convert_task().

as_task_classif(x, ...)

# S3 method for TaskClassif
as_task_classif(x, clone = FALSE, ...)

# S3 method for data.frame
as_task_classif(
  x,
  target = NULL,
  id = deparse(substitute(x)),
  positive = NULL,
  ...
)

# S3 method for DataBackend
as_task_classif(
  x,
  target = NULL,
  id = deparse(substitute(x)),
  positive = NULL,
  ...
)

# S3 method for TaskRegr
as_task_classif(
  x,
  target = NULL,
  drop_original_target = FALSE,
  drop_levels = TRUE,
  ...
)

Arguments

x

(any)
Object to convert.

...

(any)
Additional arguments.

clone

(logical(1))
If TRUE, ensures that the returned object is not the same as the input x.

target

(character(1))
Name of the target column.

id

(character(1))
Id for the new task. Defaults to the (deparsed and substituted) name of x.

positive

(character(1))
Level of the positive class. See TaskClassif.

drop_original_target

(logical(1))
If FALSE (default), the original target is added as a feature. Otherwise the original target is dropped.

drop_levels

(logical(1))
If TRUE (default), unused levels of the new target variable are dropped.

Value

TaskClassif.

Examples

as_task_classif(palmerpenguins::penguins, target = "species")
#> <TaskClassif:palmerpenguins::penguins> (344 x 8) #> * Target: species #> * Properties: multiclass #> * Features (7): #> - int (3): body_mass_g, flipper_length_mm, year #> - dbl (2): bill_depth_mm, bill_length_mm #> - fct (2): island, sex