File: setPredictThreshold.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 (22 lines) | stat: -rw-r--r-- 716 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
#' @title Set the probability threshold the learner should use.
#'
#' @description
#' See `predict.threshold` in [makeLearner] and [setThreshold].
#'
#' For complex wrappers only the top-level `predict.type` is currently set.
#'
#' @template arg_learner
#' @template arg_predictthreshold
#' @template ret_learner
#' @family predict
#' @family learner
#' @export
setPredictThreshold = function(learner, predict.threshold) {
  learner = checkLearner(learner, type = "classif")
  if (learner$predict.type != "prob") {
    stopf("predict.type = 'prob' must hold to set a predict.threshold!")
  }
  assertNumeric(predict.threshold, any.missing = FALSE)
  learner$predict.threshold = predict.threshold
  return(learner)
}