File: test_base_listLearners.R

package info (click to toggle)
r-cran-mlr 2.18.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,088 kB
  • sloc: ansic: 65; sh: 13; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,320 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
context("listLearners")

test_that("listLearners", {
  x1 = listLearners(create = FALSE, warn.missing.packages = FALSE)
  expect_data_frame(x1, min.rows = 1L, min.cols = 10)
  expect_set_equal(x1$type, c("classif", "regr", "cluster", "surv", "multilabel"))
  expect_subset(listLearnerProperties(), names(x1))

  x1a = listLearners("classif", create = FALSE, properties = "missings",
    warn.missing.packages = FALSE)
  expect_data_frame(x1a, min.rows = 10)
  expect_true(nrow(x1a) < nrow(x1))
  expect_character(x1a$note, any.missing = FALSE)

  x = listLearners(multiclass.task, create = FALSE, warn.missing.packages = FALSE)
  expect_data_frame(x, min.rows = 20, min.cols = 3)
  expect_true(all(x$type == "classif"))

  x = listLearners("surv", properties = c("factors", "missings", "weights"), create = TRUE,
    warn.missing.packages = FALSE)
  expect_list(x, "Learner", min.len = 1L)

  # test that listLearners works without a type and just requested properties,
  # we had a bug here
  x = listLearners(properties = "factors", create = FALSE)
  expect_data_frame(x, min.rows = 20, min.cols = 3)
  expect_true(length(unique(x$type)) > 3L)
})

test_that("listLearners printer (#1336)", {
  x1 = listLearners(create = FALSE, warn.missing.packages = FALSE)
  expect_silent(capture.output(print(x1), file = NULL))
})