1library(testthat) 2library(recipes) 3library(tibble) 4 5n <- 20 6set.seed(12) 7ex_dat <- data.frame(x1 = rnorm(n), 8 x2 = runif(n)) 9 10test_that('simple logit trans', { 11 rec <- recipe(~., data = ex_dat) %>% 12 step_invlogit(x1, id = "") 13 14 rec_trained <- prep(rec, training = ex_dat, verbose = FALSE) 15 rec_trans <- bake(rec_trained, new_data = ex_dat) 16 17 exp_tidy_un <- tibble(terms = "x1", id = "") 18 expect_equal(exp_tidy_un, tidy(rec, number = 1)) 19 20 exp_tidy_tr <- tibble(terms = "x1", id = "") 21 expect_equal(exp_tidy_tr, tidy(rec_trained, number = 1)) 22 23 exp_res <- as_tibble(ex_dat) 24 exp_res$x1 <- binomial()$linkinv(exp_res$x1) 25 expect_equal(rec_trans, exp_res) 26}) 27 28test_that('printing', { 29 rec <- recipe(~., data = ex_dat) %>% 30 step_invlogit(x1) 31 expect_output(print(rec)) 32 expect_output(prep(rec, training = ex_dat, verbose = TRUE)) 33}) 34