as_task_classif_st function

Convert to a Spatiotemporal Classification Task

Convert to a Spatiotemporal Classification Task

Convert an object to a TaskClassifST . This is a S3 generic for the following objects:

  1. TaskClassifST : Ensure the identity.
  2. data.frame() and mlr3::DataBackend : Provides an alternative to the constructor of TaskClassifST .
  3. sf::sf : Extracts spatial meta data before construction.
  4. mlr3::TaskRegr : Calls mlr3::convert_task().
as_task_classif_st(x, ...) ## S3 method for class 'TaskClassifST' as_task_classif_st(x, clone = FALSE, ...) ## S3 method for class 'data.frame' as_task_classif_st( x, target, id = deparse(substitute(x)), positive = NULL, coordinate_names, crs = NA_character_, coords_as_features = FALSE, label = NA_character_, ... ) ## S3 method for class 'DataBackend' as_task_classif_st( x, target, id = deparse(substitute(x)), positive = NULL, coordinate_names, crs, coords_as_features = FALSE, label = NA_character_, ... ) ## S3 method for class 'sf' as_task_classif_st( x, target = NULL, id = deparse(substitute(x)), positive = NULL, coords_as_features = FALSE, label = NA_character_, ... )

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 the data argument.

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

  • coordinate_names: (character(1))

    The column names of the coordinates in the data.

  • crs: (character(1))

    Coordinate reference system. WKT2 or EPSG string.

  • coords_as_features: (logical(1))

    If TRUE, coordinates are used as features. This is a shortcut for task$set_col_roles(c("x", "y"), role = "feature") with the assumption that the coordinates in the data are named "x" and "y".

  • label: (character(1))

    Label for the new instance. Shown in as.data.table(mlr_tasks).

Returns

TaskClassifST .

Examples

if (mlr3misc::require_namespaces(c("sf"), quietly = TRUE)) { library("mlr3") data("ecuador", package = "mlr3spatiotempcv") # data.frame as_task_classif_st(ecuador, target = "slides", positive = "TRUE", coords_as_features = FALSE, crs = "+proj=utm +zone=17 +south +datum=WGS84 +units=m +no_defs", coordinate_names = c("x", "y")) # sf ecuador_sf = sf::st_as_sf(ecuador, coords = c("x", "y"), crs = 32717) as_task_classif_st(ecuador_sf, target = "slides", positive = "TRUE") }