File: test_regr_crs.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 (31 lines) | stat: -rwxr-xr-x 904 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

test_that("regr_crs", {
  requirePackagesOrSkip("crs", default.method = "load")

  parset.list = list(
    list(nmulti = 1, cv = "none"),
    list(degree = rep(3, 12), nmulti = 1, cv = "none"),
    list(segments = rep(3, 12), nmulti = 1, cv = "none")
  )

  old.predicts.list = list()

  for (i in seq_along(parset.list)) {
    parset = parset.list[[i]]
    pars = list(regr.formula, data = regr.train)
    pars = c(pars, parset)
    suppressWarnings({
      m = do.call(crs::crs, pars)
    })
    # suppressed warnings:
    # some 'x' values beyond boundary knots may cause ill-conditioned bases
    # NaNs produced
    pred = suppressWarnings(predict(m, newdata = regr.test))
    attr(pred, "lwr") = NULL
    attr(pred, "upr") = NULL
    old.predicts.list[[i]] = pred
  }

  suppressWarnings(testSimpleParsets("regr.crs", regr.df, regr.target,
    regr.train.inds, old.predicts.list, parset.list))
})