File: test_classif_logreg.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 (23 lines) | stat: -rwxr-xr-x 903 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
test_that("classif_logreg", {
  # "did not converge":
  m = suppressWarnings(glm(formula = binaryclass.formula, data = binaryclass.train, family = binomial))

  p = predict(m, newdata = binaryclass.test, type = "response")
  p.prob = 1 - p
  p.class = as.factor(binaryclass.class.levs[ifelse(p > 0.5, 2, 1)])

  suppressWarnings(testSimple("classif.logreg", binaryclass.df, binaryclass.target, binaryclass.train.inds, p.class))


  suppressWarnings(testProb("classif.logreg", binaryclass.df, binaryclass.target, binaryclass.train.inds, p.prob))

  tt = function(formula, data) {
    glm(formula, data = data, family = binomial)
  }
  tp = function(model, newdata) {
    p = predict(model, newdata, type = "response")
    as.factor(binaryclass.class.levs[ifelse(p > 0.5, 2, 1)])
  }

  suppressWarnings(testCV("classif.logreg", binaryclass.df, binaryclass.target, tune.train = tt, tune.predict = tp))
})