@@ -4,9 +4,9 @@ library(rlang)
44library(tibble )
55
66context(" test-nullmodel" )
7- source(" helpers.R" )
7+ source(test_path( " helpers.R" ) )
88source(test_path(" helper-objects.R" ))
9- hpc <- hpc_data [1 : 150 , c(2 : 5 , 8 )]
9+ hpc <- hpc_data [1 : 150 , c(2 : 5 , 8 )] % > % as.data.frame()
1010
1111test_that(' primary arguments' , {
1212 basic <- null_model(mode = " regression" )
@@ -44,7 +44,7 @@ test_that('bad input', {
4444
4545# ------------------------------------------------------------------------------
4646
47- num_pred <- names(phc )[1 : 3 ]
47+ num_pred <- names(hpc )[1 : 3 ]
4848hpc_bad_form <- as.formula(class ~ term )
4949hpc_basic <- null_model(mode = " regression" ) %> % set_engine(" parsnip" )
5050
@@ -92,8 +92,8 @@ test_that('nullmodel execution', {
9292
9393test_that(' nullmodel prediction' , {
9494
95- uni_pred <- tibble(.pred = rep(3.758 , 5 ))
96- inl_pred <- rep(3.758 , 5 )
95+ uni_pred <- tibble(.pred = rep(30.1 , 5 ))
96+ inl_pred <- rep(30.1 , 5 )
9797 mw_pred <- tibble(gear = rep(3.6875 , 5 ),
9898 carb = rep(2.8125 , 5 ))
9999
@@ -103,14 +103,18 @@ test_that('nullmodel prediction', {
103103 y = hpc $ num_pending
104104 )
105105
106- expect_equal(uni_pred , predict(res_xy , new_data = hpc [1 : 5 , num_pred ]))
106+ expect_equal(uni_pred ,
107+ predict(res_xy , new_data = hpc [1 : 5 , num_pred ]),
108+ tolerance = .01 )
107109
108110 res_form <- fit(
109111 hpc_basic ,
110112 num_pending ~ log(compounds ) + class ,
111- data = hpc_basic
113+ data = hpc
112114 )
113- expect_equal(inl_pred , predict(res_form , hpc [1 : 5 , ])$ .pred )
115+ expect_equal(inl_pred ,
116+ predict(res_form , hpc [1 : 5 , ])$ .pred ,
117+ tolerance = .01 )
114118
115119 # Multivariate y
116120 res <- fit(
0 commit comments