File: test_classif_binomial.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 (36 lines) | stat: -rwxr-xr-x 1,096 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
33
34
35
36

test_that("classif_binomial", {
  parset.list1 = list(
    list(family = binomial),
    list(family = binomial(link = "logit")),
    list(family = binomial(link = "cloglog"))
  )

  parset.list2 = list(
    list(),
    list(link = "logit"),
    list(link = "cloglog")
  )

  old.predicts.list = list()
  old.probs.list = list()
  nof = 1:55 # remove feats

  for (i in seq_along(parset.list1)) {
    parset = parset.list1[[i]]
    set.seed(getOption("mlr.debug.seed"))
    m = glm(formula = binaryclass.formula, data = binaryclass.train[, -nof], family = parset$family)
    p = predict(m, newdata = binaryclass.test[, -nof], type = "response")
    p = 1 - p
    p.class = as.factor(binaryclass.class.levs[ifelse(p > 0.5, 1, 2)])
    old.predicts.list[[i]] = p.class
    old.probs.list[[i]] = p
  }

  testSimpleParsets("classif.binomial", binaryclass.df[, -nof],
    binaryclass.target, binaryclass.train.inds,
    old.predicts.list, parset.list2)
  testProbParsets("classif.binomial", binaryclass.df[, -nof],
    binaryclass.target, binaryclass.train.inds,
    old.probs.list, parset.list2)
})