tidymodels / rsample

Compare 1ed3567 ... +1 ... 67a9d51

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 3 of 7 files from the diff.

@@ -100,11 +100,6 @@
Loading
100 100
           subclass = c("vfold_cv", "rset"))
101 101
}
102 102
103 -
# Get the indices of the analysis set from the assessment set
104 -
vfold_complement <- function(ind, n) {
105 -
  list(analysis = setdiff(1:n, ind),
106 -
       assessment = ind)
107 -
}
108 103
109 104
vfold_splits <- function(data, v = 10, strata = NULL, breaks = 4) {
110 105
  if (!is.numeric(v) || length(v) != 1)
@@ -125,7 +120,7 @@
Loading
125 120
    indices <- split_unnamed(stratas$idx, stratas$folds)
126 121
  }
127 122
128 -
  indices <- lapply(indices, vfold_complement, n = n)
123 +
  indices <- lapply(indices, default_complement, n = n)
129 124
130 125
  split_objs <- purrr::map(indices, make_splits, data = data, class = "vfold_split")
131 126
  tibble::tibble(splits = split_objs,

@@ -1,10 +1,18 @@
Loading
1 1
#' Determine the Assessment Samples
2 2
#'
3 -
#' Given an `rsplit` object, `complement` will determine which
3 +
#' This method and function help find which data belong in the analysis and
4 +
#' assessment sets.
5 +
#'
6 +
#' Given an `rsplit` object, `complement()` will determine which
4 7
#'   of the data rows are contained in the assessment set. To save space,
5 8
#'   many of the `rset` objects will not contain indices for the
6 9
#'   assessment split.
7 10
#'
11 +
#' `rsplit_complement()` handles the determination for sets for most resampling
12 +
#' methods. Unless the row indices for the assessment set are already
13 +
#' determined, this function selects all of the rows that are not in the
14 +
#' analysis set and returns those as the assessment set.
15 +
#'
8 16
#' @param x An `rsplit` object
9 17
#' @param ... Not currently used
10 18
#' @return A integer vector.
@@ -20,37 +28,29 @@
Loading
20 28
  UseMethod("complement")
21 29
22 30
#' @export
23 -
complement.vfold_split <- function(x, ...) {
31 +
#' @rdname complement
32 +
rsplit_complement <- function(x, ...) {
24 33
  if (!is_missing_out_id(x)) {
25 34
    return(x$out_id)
26 35
  } else {
27 -
    setdiff(1:nrow(x$data), x$in_id)
36 +
    (1:nrow(x$data))[-unique(x$in_id)]
28 37
  }
29 38
}
39 +
30 40
#' @export
31 -
complement.mc_split  <- complement.vfold_split
41 +
complement.vfold_split <- rsplit_complement
32 42
#' @export
33 -
complement.val_split <- complement.vfold_split
43 +
complement.mc_split  <- rsplit_complement
34 44
#' @export
35 -
complement.loo_split <- complement.vfold_split
45 +
complement.val_split <- rsplit_complement
36 46
#' @export
37 -
complement.group_vfold_split <- complement.vfold_split
47 +
complement.loo_split <- rsplit_complement
38 48
#' @export
39 -
complement.boot_split <- function(x, ...) {
40 -
  if (!is_missing_out_id(x)) {
41 -
    return(x$out_id)
42 -
  } else {
43 -
    (1:nrow(x$data))[-unique(x$in_id)]
44 -
  }
45 -
}
49 +
complement.group_vfold_split <- rsplit_complement
46 50
#' @export
47 -
complement.perm_split <- function(x, ...) {
48 -
  if (!is_missing_out_id(x)) {
49 -
    return(x$out_id)
50 -
  } else {
51 -
    (1:nrow(x$data))[-unique(x$in_id)]
52 -
  }
53 -
}
51 +
complement.boot_split <- rsplit_complement
52 +
#' @export
53 +
complement.perm_split <- rsplit_complement
54 54
#' @export
55 55
complement.rof_split <- function(x, ...) {
56 56
  get_stored_out_id(x)
@@ -91,6 +91,18 @@
Loading
91 91
  }
92 92
}
93 93
94 +
#' Get the indices of the analysis set from the assessment set
95 +
#' @param ind A vector of integers for which rows of data belong in the
96 +
#' assessment set.
97 +
#' @param n A single integer for the total number of rows in the data set.
98 +
#' @return A named list of integer vectors.
99 +
#' @export
100 +
#' @keywords internal
101 +
default_complement <- function(ind, n) {
102 +
  list(analysis = setdiff(1:n, ind),
103 +
       assessment = unique(ind))
104 +
}
105 +
94 106
95 107
#' Add Assessment Indices
96 108
#'

@@ -99,7 +99,7 @@
Loading
99 99
    full_join(keys, by = "..group") %>%
100 100
    arrange(..index)
101 101
  indices <- split_unnamed(data_ind$..index, data_ind$..folds)
102 -
  indices <- lapply(indices, vfold_complement, n = nrow(data))
102 +
  indices <- lapply(indices, default_complement, n = nrow(data))
103 103
  split_objs <-
104 104
    purrr::map(indices,
105 105
               make_splits,

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
R 0.06% 82.33%
Project Totals (28 files) 82.33%
Loading