File: RLearner_classif_adaboostm1.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 (34 lines) | stat: -rw-r--r-- 1,421 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
32
33
34
#' @export
makeRLearner.classif.adaboostm1 = function() {
  makeRLearnerClassif(
    cl = "classif.adaboostm1",
    package = "RWeka",
    par.set = makeParamSet(
      makeIntegerLearnerParam(id = "P", default = 100L, lower = 90L),
      makeLogicalLearnerParam(id = "Q", default = FALSE),
      makeNumericLearnerParam(id = "S", default = 1L),
      makeIntegerLearnerParam(id = "I", default = 10L, lower = 1L),
      makeLogicalLearnerParam(id = "D", default = FALSE, requires = quote(!U)),
      makeUntypedLearnerParam(id = "W", default = list("DecisionStump")),
      makeLogicalLearnerParam(id = "output-debug-info", default = FALSE, tunable = FALSE)
    ),
    properties = c("twoclass", "multiclass", "numerics", "factors", "prob"),
    name = "ada Boosting M1",
    short.name = "adaboostm1",
    note = "NAs are directly passed to WEKA with `na.action = na.pass`.",
    callees = c("AdaBoostM1", "Weka_control")
  )
}

#' @export
trainLearner.classif.adaboostm1 = function(.learner, .task, .subset, .weights = NULL, ...) {
  f = getTaskFormula(.task)
  ctrl = RWeka::Weka_control(...)
  RWeka::AdaBoostM1(f, data = getTaskData(.task, .subset), control = ctrl, na.action = na.pass)
}

#' @export
predictLearner.classif.adaboostm1 = function(.learner, .model, .newdata, ...) {
  type = switch(.learner$predict.type, prob = "prob", "class")
  predict(.model$learner.model, newdata = .newdata, type = type, ...)
}