File: checkAggrBeforeResample.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 (24 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# check whether rdesc$predict is set, so that the requiring properties of the measure are satisfied
# called the beginning of resample
checkAggrBeforeResample = function(measure, rdesc) {
  a = measure$aggr
  p = a$properties
  pred = rdesc$predict
  p.allowed = if (all(c("req.train", "req.test") %in% p)) {
    "both"
  } else if ("req.train" %in% p) {
    c("train", "both")
  } else if ("req.test" %in% p) {
    c("test", "both")
  } else {
    c("train", "test", "both")
  }
  if (pred %nin% p.allowed) {
    stopf("Aggregation '%s' not compatible with resampling! You have to set arg 'predict' to %s in your resample object, instead it is '%s'!", a$id, stri_paste("'", p.allowed, "'", collapse = " or "), pred)
  }
}

# map the checker over multiple measures
checkAggrsBeforeResample = function(measures, rdesc) {
  lapply(measures, checkAggrBeforeResample, rdesc = rdesc)
}