File: test_base_convertMLBenchObjToTask.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 (25 lines) | stat: -rw-r--r-- 865 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
context("convertMLBenchObjToTask")

test_that("convertMLbenchObjToTask", {
  requirePackagesOrSkip("mlbench")
  # get all mlbench.* functions, 1spiral does not work
  fs = ls("package:mlbench", pattern = "mlbench")
  n = 77L
  for (f in setdiff(fs, "mlbench.1spiral")) {
    task = convertMLBenchObjToTask(f, n = n)
    expect_is(task, "Task")
    # for some, n is not properly respected in mlbench
    if (f %nin% c("mlbench.corners", "mlbench.hypercube", "mlbench.simplex")) {
      expect_equal(getTaskSize(task), n)
    }
  }

  # get all mlbench datasets, HouseVotes84 and Ozone have NAs in target col
  ds = data(package = "mlbench")
  ds = ds$results[, "Item"]
  for (d in setdiff(ds, c("HouseVotes84", "Ozone"))) {
    task = convertMLBenchObjToTask(d, n = n)
    expect_is(task, "Task")
    expect_equal(getTaskId(task), d)
  }
})