File: test_featsel_rankSimpleFilters.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 (22 lines) | stat: -rw-r--r-- 844 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
context("filters")

cat("rankSimpleFilters")
test_that("base filters of ensemble filters are ranked correctly", {
  requirePackagesOrSkip("Hmisc", default.method = "load")

  filters.ranked = rankBaseFilters(task.filters.rank,
    method = c("univariate.model.score", "variance"),
    nselect = 9, more.args = list())

  # split into groups to check the ordering of vars "value" and "rank" for each
  data.split = split(filters.ranked, filters.ranked$filter)

  foo = lapply(data.split, function(x) {
    expect_false(is.unsorted(x[["value"]]))
    expect_false(is.unsorted(x[["rank"]]))
  })

  # check that the highest value has also the highest rank
  expect_true(which.max(data.split[[1]]$value) == which.max(data.split[[1]]$rank))
  expect_true(which.max(data.split[[2]]$value) == which.max(data.split[[2]]$rank))
})