# generate_xgb_folds ------------------------------------------------------
test_that("correct number of xgb_folds", {
expect_equal(length(generate_xgb_folds(5, 5)), 5)
})
test_that("folds crossvalidation works", {
expect_equal(length(generate_xgb_folds(5, 5)), 5)
})
# generate_reg_metrics ----------------------------------------------------
# generate_xgb_params -----------------------------------------------------
test_that("xgb_params seed works", {
expect_equal(generate_xgb_params(5), generate_xgb_params(5))
})
test_that("xgb_params is the correct length", {
expect_equal(nrow(generate_xgb_params(5)), 5)
})
# deviance ----------------------------------------------------------------
set.seed(1234)
n <- 1000
x <- runif(n)
mean <- exp(x)
y <- rpois(n,mean)
mdl <- glm(y~x, family=poisson)
y_hat <- predict(mdl, data = x, type = "response")
test_that("residual deviance metrics are correct", {
expect_equal(round(mdl$deviance, 3), round(deviance(y, y_hat), 3))
})
rm(n, x, mean, y, mdl, y_hat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.