File: getClassWeightParam.R

package info (click to toggle)
r-cran-mlr 2.18.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,088 kB
  • sloc: ansic: 65; sh: 13; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,049 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
25
26
27
28
29
30
31
#' @title Get the class weight parameter of a learner.
#'
#' @description
#' Gets the class weight parameter of a learner.
#'
#' @template arg_learner
#' @param lrn.id ([character])\cr
#'   Only used for `BaseEnsembles`. It is possible that multiple learners in a base
#'   ensemble have a class weight param. Specify the learner from which the class weight should
#'   be extracted.
#' @return [numeric] [LearnerParam]:
#'   A numeric parameter object, containing the class weight parameter of the given learner.
#' @family learner
#' @export
getClassWeightParam = function(learner, lrn.id = NULL) {
  UseMethod("getClassWeightParam")
}

#' @export
getClassWeightParam.character = function(learner, ...) {
  learner = checkLearner(learner, "classif", props = "class.weights")
  getClassWeightParam(learner, ...)
}


#' @export
getClassWeightParam.Learner = function(learner, ...) {
  learner = checkLearner(learner, "classif", props = "class.weights")
  weight.param.name = learner$class.weights.param
  learner$par.set$pars[[weight.param.name]]
}