tests/testthat/test_default_fallback.R

test_that("fallback = default_fallback() works", {
  learner = lrn("classif.rpart")
  fallback = default_fallback(learner)

  expect_class(fallback, "LearnerClassifFeatureless")
  expect_equal(fallback$predict_type, "response")

  learner = lrn("classif.rpart", predict_type = "prob")
  fallback = default_fallback(learner)

  expect_class(fallback, "LearnerClassifFeatureless")
  expect_equal(fallback$predict_type, "prob")

  learner = lrn("regr.rpart")
  fallback = default_fallback(learner)

  expect_class(fallback, "LearnerRegrFeatureless")
  expect_equal(fallback$predict_type, "response")

  learner = lrn("regr.debug", predict_type = "se")
  fallback = default_fallback(learner)

  expect_class(fallback, "LearnerRegrFeatureless")
  expect_equal(fallback$predict_type, "se")

  learner = lrn("regr.debug",
    predict_type = "quantiles",
    quantiles = c(0.1, 0.9),
    quantile_response = 0.1)
  fallback = default_fallback(learner)

  expect_class(fallback, "LearnerRegrFeatureless")
  expect_equal(fallback$predict_type, "quantiles")
  expect_equal(fallback$quantiles, c(0.1, 0.9))
  expect_equal(fallback$quantile_response, 0.1)
})

Try the mlr3 package in your browser

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

mlr3 documentation built on Oct. 18, 2024, 5:11 p.m.