File: test_regr_bartMachine.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 (35 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download
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
35

test_that("regr_bartMachine", {
  requirePackagesOrSkip("bartMachine", default.method = "load")

  parset.list = list(
    list(num_burn_in = 10L, num_iterations_after_burn_in = 10L,
      run_in_sample = FALSE,
      seed = getOption("mlr.debug.seed")
    ),
    list(num_burn_in = 10L, num_iterations_after_burn_in = 10L, alpha = 0.8,
      num_trees = 25L, run_in_sample = FALSE,
      seed = getOption("mlr.debug.seed")
    )
  )

  old.predicts.list = list()
  xind = names(regr.train) != regr.target

  for (i in seq_along(parset.list)) {
    parset = parset.list[[i]]
    pars = list(y = regr.train[, regr.target], X = regr.train[, xind],
      verbose = FALSE)
    pars = c(pars, parset)
    m = do.call(bartMachine::bartMachine, pars)
    set.seed(getOption("mlr.debug.seed"))
    old.predicts.list[[i]] = predict(m, new_data = regr.test[, xind])
  }

  testSimpleParsets("regr.bartMachine", regr.df, regr.target, regr.train.inds,
    old.predicts.list, parset.list)

  for (i in seq_along(parset.list)) {
    expect_true(length(old.predicts.list[[i]]) == nrow(regr.test))
  }
})