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

  1. TaskClassifST: ensure the identity

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

  3. sf::sf.

as_task_classif_st(x, ...)

# S3 method for TaskClassifST
as_task_classif_st(x, clone = FALSE, ...)

# S3 method for data.frame
as_task_classif_st(
  x,
  target = NULL,
  id = deparse(substitute(x)),
  positive = NULL,
  crs = NA,
  coords_as_features = FALSE,
  coordinate_names = NA,
  ...
)

# S3 method for DataBackend
as_task_classif_st(
  x,
  target = NULL,
  id = deparse(substitute(x)),
  positive = NULL,
  crs = NA,
  coords_as_features = FALSE,
  coordinate_names = c("x", "y"),
  ...
)

# S3 method for sf
as_task_classif_st(
  x,
  target = NULL,
  id = deparse(substitute(x)),
  positive = NULL,
  coords_as_features = FALSE,
  ...
)

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.

crs

[character(1)]
Coordinate reference system. Either a PROJ string or an EPSG code.

coords_as_features

[logical(1)]
Whether the coordinates should also be used as features.

coordinate_names

(character())
The variables names of the coordinates in the data.

Value

TaskClassifST.

Examples

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"))
#> <TaskClassifST:ecuador> (751 x 11) #> * Target: slides #> * Properties: twoclass #> * Features (10): #> - dbl (10): carea, cslope, dem, distdeforest, distroad, #> distslidespast, hcurv, log.carea, slope, vcurv #> * Coordinates: #> x y #> 1: 712882.5 9560002 #> 2: 715232.5 9559582 #> 3: 715392.5 9560172 #> 4: 715042.5 9559312 #> 5: 715382.5 9560142 #> --- #> 747: 714472.5 9558482 #> 748: 713142.5 9560992 #> 749: 713322.5 9560562 #> 750: 715392.5 9557932 #> 751: 713802.5 9560862
# sf ecuador_sf = sf::st_as_sf(ecuador, coords = c("x", "y"), crs = 32717) as_task_classif_st(ecuador_sf, target = "slides", positive = "TRUE")
#> <TaskClassifST:ecuador_sf> (751 x 11) #> * Target: slides #> * Properties: twoclass #> * Features (10): #> - dbl (10): carea, cslope, dem, distdeforest, distroad, #> distslidespast, hcurv, log.carea, slope, vcurv #> * Coordinates: #> X Y #> 1: 712882.5 9560002 #> 2: 715232.5 9559582 #> 3: 715392.5 9560172 #> 4: 715042.5 9559312 #> 5: 715382.5 9560142 #> --- #> 747: 714472.5 9558482 #> 748: 713142.5 9560992 #> 749: 713322.5 9560562 #> 750: 715392.5 9557932 #> 751: 713802.5 9560862
# TaskClassifST task = tsk("ecuador") as_task_classif_st(task)
#> <TaskClassifST:ecuador> (751 x 11) #> * Target: slides #> * Properties: twoclass #> * Features (10): #> - dbl (10): carea, cslope, dem, distdeforest, distroad, #> distslidespast, hcurv, log.carea, slope, vcurv #> * Coordinates: #> x y #> 1: 712882.5 9560002 #> 2: 715232.5 9559582 #> 3: 715392.5 9560172 #> 4: 715042.5 9559312 #> 5: 715382.5 9560142 #> --- #> 747: 714472.5 9558482 #> 748: 713142.5 9560992 #> 749: 713322.5 9560562 #> 750: 715392.5 9557932 #> 751: 713802.5 9560862