tests/testthat/test-performance_cv.R

model <- lm(mpg ~ wt + cyl, data = mtcars)

set.seed(123)
out <- performance_cv(model)

test_that("performance_cv", {
  expect_equal(out$MSE, 5.91153, tolerance = 1e-3)
  expect_equal(colnames(out), c("MSE", "RMSE", "R2"), tolerance = 1e-3)
})

set.seed(123)
out <- performance_cv(model, metrics = c("MSE", "R2"))

test_that("performance_cv", {
  expect_equal(out$MSE, 5.91153, tolerance = 1e-3)
  expect_equal(colnames(out), c("MSE", "R2"), tolerance = 1e-3)
})

Try the performance package in your browser

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

performance documentation built on Oct. 19, 2024, 1:07 a.m.