File: test_classif_bst.R

package info (click to toggle)
r-cran-mlr 2.19.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,392 kB
  • sloc: ansic: 65; sh: 13; makefile: 5
file content (32 lines) | stat: -rwxr-xr-x 996 bytes parent folder | download | duplicates (2)
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

test_that("classif_bst", {
  requirePackagesOrSkip("bst", default.method = "load")

  parset.list1 = list(
    list(),
    list(cost = 0.6, family = "gaussian"),
    list(ctrl = bst::bst_control(mstop = 40L)),
    list(learner = "tree", control.tree = list(maxdepth = 2L))
  )

  parset.list2 = list(
    list(),
    list(cost = 0.6, family = "gaussian"),
    list(mstop = 40L),
    list(Learner = "tree", maxdepth = 2L)
  )

  old.predicts.list = list()

  for (i in seq_along(parset.list1)) {
    parset = parset.list1[[i]]
    parset$y = ifelse(binaryclass.train[, binaryclass.class.col] == binaryclass.class.levs[2], 1, -1)
    parset$x = binaryclass.train[, -binaryclass.class.col]
    m = do.call(bst::bst, parset)
    p = predict(m, binaryclass.test)
    old.predicts.list[[i]] = ifelse(p > 0, binaryclass.class.levs[2], binaryclass.class.levs[1])
  }

  testSimpleParsets("classif.bst", binaryclass.df, binaryclass.target,
    binaryclass.train.inds, old.predicts.list, parset.list2)
})