mlr-org / mlr3spatiotempcv
Showing 1 of 3 files from the diff.
Other files ignored by Codecov

@@ -0,0 +1,54 @@
Loading
1 +
#' @title Convert to a SpatioTemporal Classification Task
2 +
#'
3 +
#' @description
4 +
#' Convert object to a [TaskClassifST].
5 +
#' This is a S3 generic, specialized for at least the following objects:
6 +
#'
7 +
#' 1. [TaskClassifST]: ensure the identity
8 +
#' 2. [data.frame()] and [DataBackend]: provides an alternative to the constructor of [TaskClassifST].
9 +
#' 2. [sf::sf].
10 +
#'
11 +
#' @inheritParams mlr3::as_task_classif
12 +
#' @param coordinate_names (`character()`)\cr 
13 +
#'   Name of the coordinate columns. Defaults to `c("x", "y")`.
14 +
#'
15 +
#' @return [TaskClassifST].
16 +
#' @export
17 +
#' @examples
18 +
#' data("ecuador", package = "mlr3spatiotempcv")
19 +
#' as_task_classif_st(ecuador, target = "slides", positive = "TRUE")
20 +
#'
21 +
#' ecuador_sf = sf::st_as_sf(ecuador, coords = c("x", "y"), crs = 4326)
22 +
#' as_task_classif_st(ecuador_sf, target = "slides", positive = "TRUE")
23 +
as_task_classif_st = function(x, ...) {
24 +
  UseMethod("as_task_classif_st")
25 +
}
26 +
27 +
28 +
#' @rdname as_task_classif_st
29 +
#' @export
30 +
as_task_classif_st.TaskClassifST = function(x, clone = FALSE, ...) { # nolint
31 +
  if (clone) x$clone() else x
32 +
}
33 +
34 +
35 +
#' @rdname as_task_classif_st
36 +
#' @export
37 +
as_task_classif_st.data.frame = function(x, target = NULL, id = deparse(substitute(x)), positive = NULL, coordinate_names = c("x", "y"), ...) { # nolint
38 +
  TaskClassifST$new(id = id, backend = x, target = target, positive = positive,
39 +
    extra_args = list(coordinate_names = coordinate_names))
40 +
}
41 +
42 +
43 +
#' @rdname as_task_classif_st
44 +
#' @export
45 +
as_task_classif_st.DataBackend = function(x, target = NULL, id = deparse(substitute(x)), positive = NULL, coordinate_names = c("x", "y"), ...) { # nolint
46 +
  TaskClassifST$new(id = id, backend = x, target = target, positive = positive,
47 +
    extra_args = list(coordinate_names = coordinate_names))
48 +
}
49 +
50 +
#' @rdname as_task_classif_st
51 +
#' @export
52 +
as_task_classif_st.sf = function(x, target = NULL, id = deparse(substitute(x)), positive = NULL, ...) { # nolint
53 +
  TaskClassifST$new(id = id, backend = x, target = target, positive = positive)
54 +
}
Files Coverage
R 78.72%
Project Totals (25 files) 78.72%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading