tests/testthat/test_regr_lm.R

test_that("autotest", {
  learner = mlr3::lrn("regr.lm")
  expect_learner(learner)
  result = run_autotest(learner)
  expect_true(result, info = result$error)
})

test_that("contrasts", {
  task = tsk("boston_housing")
  learner = mlr3::lrn("regr.lm")

  learner$train(task)
  coefs1 = coef(learner$model)
  names(coefs1)

  opts = list(contrasts = c(ordered = "contr.poly", unordered = "contr.poly"))
  old_opts = options(opts)
  on.exit(options(old_opts))

  learner$train(task)
  coefs2 = coef(learner$model)

  expect_setequal(names(coefs1), names(coefs2))
})

Try the mlr3learners package in your browser

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

mlr3learners documentation built on June 28, 2024, 5:09 p.m.