File: HoldoutInstance_make_fixed.R

package info (click to toggle)
r-cran-mlr 2.19.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,264 kB
  • sloc: ansic: 65; sh: 13; makefile: 5
file content (21 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#' Generate a fixed holdout instance for resampling.
#'
#' @param train.inds ([integer])\cr
#'   Indices for training set.
#' @param test.inds ([integer])\cr
#'   Indices for test set.
#' @param size (`integer(1)`)\cr
#'   Size of the data set to resample.
#'   The function needs to know the largest possible index of the whole data set.
#' @return ([ResampleInstance]).
#' @export
makeFixedHoldoutInstance = function(train.inds, test.inds, size) {
  train.inds = asInteger(train.inds, any.missing = FALSE)
  test.inds = asInteger(test.inds, any.missing = FALSE)
  size = asInt(size, lower = 1L)
  rdesc = makeResampleDesc("Holdout", split = length(train.inds) / size)
  rin = makeResampleInstance(rdesc, size = size)
  rin$train.inds[[1L]] = train.inds
  rin$test.inds[[1L]] = test.inds
  return(rin)
}