tests/testthat/test-rand_forest.R

test_that('updating', {
  expect_snapshot(
    rand_forest(mode = "regression", mtry = 2) %>%
      set_engine("randomForest", sampsize = 10) %>%
      update(mtry = tune(), sampsize = tune())
  )
})

test_that('bad input', {
  expect_snapshot(res <-
                    translate(rand_forest(mode = "classification") %>%
                                set_engine(NULL)),
                  error = TRUE)
  expect_snapshot(error = TRUE, rand_forest(mode = "time series"))
  expect_snapshot(error = TRUE, translate(rand_forest(mode = "classification") %>% set_engine("wat?")))
})

test_that("check_args() works", {
  # Here for completeness, no checking is done
  expect_true(TRUE)
})

Try the parsnip package in your browser

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

parsnip documentation built on April 4, 2025, 1:53 a.m.