@@ -4,9 +4,9 @@ library(rlang)
4
4
library(tibble )
5
5
6
6
context(" test-nullmodel" )
7
- source(" helpers.R" )
7
+ source(test_path( " helpers.R" ) )
8
8
source(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()
10
10
11
11
test_that(' primary arguments' , {
12
12
basic <- null_model(mode = " regression" )
@@ -44,7 +44,7 @@ test_that('bad input', {
44
44
45
45
# ------------------------------------------------------------------------------
46
46
47
- num_pred <- names(phc )[1 : 3 ]
47
+ num_pred <- names(hpc )[1 : 3 ]
48
48
hpc_bad_form <- as.formula(class ~ term )
49
49
hpc_basic <- null_model(mode = " regression" ) %> % set_engine(" parsnip" )
50
50
@@ -92,8 +92,8 @@ test_that('nullmodel execution', {
92
92
93
93
test_that(' nullmodel prediction' , {
94
94
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 )
97
97
mw_pred <- tibble(gear = rep(3.6875 , 5 ),
98
98
carb = rep(2.8125 , 5 ))
99
99
@@ -103,14 +103,18 @@ test_that('nullmodel prediction', {
103
103
y = hpc $ num_pending
104
104
)
105
105
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 )
107
109
108
110
res_form <- fit(
109
111
hpc_basic ,
110
112
num_pending ~ log(compounds ) + class ,
111
- data = hpc_basic
113
+ data = hpc
112
114
)
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 )
114
118
115
119
# Multivariate y
116
120
res <- fit(
0 commit comments