tests/testthat/test_pecs.R

set.seed(1)
task = tsk("rats")$filter(sample(300, 5))

test_that("pecs.list", {
  skip_on_cran()
  learns = lrns(c("surv.kaplan", "surv.coxph"))
  expect_error(pecs(learns), "trained survival learners")
  suppressWarnings({
    lapply(learns, function(x) x$train(task))
  })
  expect_error(pecs(learns, meas = "sdsd"))
  expect_silent(pecs(learns, task = task, meas = "logloss", n = 10))
  expect_error(pecs(learns, times = 1))
  expect_error(pecs(learns, times = -10:-5, task = task), "Not enough")
})

test_that("pecs.PredictionSurv", {
  skip_on_cran()
  suppressWarnings({
    p = lrn("surv.coxph")$train(task)$predict(task)
  })
  expect_silent(pecs(p))
})

Try the mlr3proba package in your browser

Any scripts or data that you put into this service are public.

mlr3proba documentation built on April 25, 2022, 5:07 p.m.