@@ -99,20 +99,20 @@ test_that("warning raised if variance of variable is 0", {
99
99
})
100
100
101
101
test_that(" all models work and produce the correct output" , {
102
- functions <- list (" rf" = random_forest_model ,
103
- " bag_mars" = bagged_mars_model ,
104
- " mars" = mars_model ,
105
- " linear" = linear_model ,
106
- " svm" = svm_model ,
107
- " boosting" = gradient_boosting_model ,
108
- " mpl" = mlp_model )
102
+ functions <- list (" rf" = rlang :: expr( random_forest_model ) ,
103
+ " bag_mars" = rlang :: expr( bagged_mars_model ) ,
104
+ " mars" = rlang :: expr( mars_model ) ,
105
+ " linear" = rlang :: expr( linear_model ) ,
106
+ " svm" = rlang :: expr( svm_model ) ,
107
+ " boosting" = rlang :: expr( gradient_boosting_model ) ,
108
+ " mpl" = rlang :: expr( mlp_model ) )
109
109
110
110
ncols <- 5
111
111
expr <- generate_random_tibble(100 , ncols )
112
112
misty.views <- create_initial_view(expr )
113
113
114
- misty.test <- purrr :: map (functions , function (fun ) {
115
- suppressWarnings(misty.results <- run_misty(misty.views , model.function = fun ) %> %
114
+ misty.test <- purrr :: walk (functions , function (fun ) {
115
+ suppressWarnings(misty.results <- run_misty(misty.views , model.function = !! fun ) %> %
116
116
collect_results()
117
117
)
118
118
expect_true(dir.exists(" results" ))
@@ -135,114 +135,18 @@ test_that("ellipsis arguments can be passed to the provided ML models", {
135
135
misty.views <- create_initial_view(expr ) %> %
136
136
add_paraview(positions = pos , l = 10 )
137
137
138
- # random forest
139
- start <- Sys.time()
140
- suppressWarnings(
141
- misty.test <- run_misty(misty.views , model.function = random_forest_model )
142
- )
143
- end <- Sys.time()
144
- first.run = end - start
145
-
146
- start <- Sys.time()
147
- suppressWarnings(
148
- misty.test <- run_misty(misty.views , model.function = random_forest_model ,
149
- num.trees = 2000 )
150
- )
151
- end <- Sys.time()
152
- second.run = end - start
153
- testthat :: expect_true(first.run < second.run )
154
-
155
- # bagged mars
156
- start <- Sys.time()
157
- suppressWarnings(
158
- misty.test <- run_misty(misty.views , model.function = bagged_mars_model ,
159
- degree = 1 )
160
- )
161
- end <- Sys.time()
162
- first.run = end - start
163
-
164
- start <- Sys.time()
165
- suppressWarnings(
166
- misty.test <- run_misty(misty.views , model.function = bagged_mars_model ,
167
- n.bags = 50 )
138
+ suppressWarnings(misty.test <- run_misty(misty.views , model.function = mars_model ,
139
+ degree = 3 , nk = 30 , cached = TRUE )
168
140
)
169
- end <- Sys.time()
170
- second.run = end - start
171
- testthat :: expect_true(first.run < second.run )
172
141
173
- # mars
174
- start <- Sys.time()
175
- suppressWarnings(
176
- misty.test <- run_misty(misty.views , model.function = mars_model ,
177
- degree = 3 , nk = 30 )
178
- )
179
- end <- Sys.time()
180
- first.run = end - start
181
-
182
- start <- Sys.time()
183
- suppressWarnings(
184
- misty.test <- run_misty(misty.views , model.function = mars_model ,
185
- degree = 3 , nk = 30 )
186
- )
187
- end <- Sys.time()
188
- second.run = end - start
189
- testthat :: expect_true(first.run < second.run )
190
-
191
- # svm
192
- start <- Sys.time()
193
- suppressWarnings(
194
- misty.test <- run_misty(misty.views , model.function = svm_model ,
195
- C = 1 )
196
- )
197
- end <- Sys.time()
198
- first.run = end - start
199
-
200
- start <- Sys.time()
201
- suppressWarnings(
202
- misty.test <- run_misty(misty.views , model.function = svm_model ,
203
- C = 100 )
204
- )
205
- end <- Sys.time()
206
- second.run = end - start
207
- testthat :: expect_true(first.run < second.run )
208
-
209
- # gradient boosting
210
- start <- Sys.time()
211
- suppressWarnings(
212
- misty.test <- run_misty(misty.views , model.function = gradient_boosting_model ,
213
- booster = " gbtree" , nrounds = 10 )
214
- )
215
- end <- Sys.time()
216
- first.run = end - start
217
-
218
- start <- Sys.time()
219
- suppressWarnings(
220
- misty.test <- run_misty(misty.views , model.function = gradient_boosting_model ,
221
- booster = " gbtree" , nrounds = 20 )
222
- )
223
- end <- Sys.time()
224
- second.run = end - start
225
- testthat :: expect_true(first.run < second.run )
226
-
227
- # multi-layer perceptron
228
- start <- Sys.time()
229
- suppressWarnings(
230
- misty.test <- run_misty(misty.views , model.function = mlp_model ,
231
- size = c(1 ), maxit = 1 )
232
- )
233
- end <- Sys.time()
234
- first.run = end - start
235
-
236
- start <- Sys.time()
237
- suppressWarnings(
238
- misty.test <- run_misty(misty.views , model.function = mlp_model ,
239
- size = c(10 ), maxit = 100 )
240
- )
241
- end <- Sys.time()
242
- second.run = end - start
243
- testthat :: expect_true(first.run < second.run )
244
-
245
- unlink(" results" , recursive = TRUE )
142
+ cache.folder <- paste0(" .misty.temp/" , misty.views [[" misty.uniqueid" ]])
143
+ cached.files <- list.files(cache.folder )
144
+
145
+ expect_true(all(stringr :: str_detect(cached.files , " mars_model" )) &
146
+ all(stringr :: str_detect(cached.files , " degree.3.nk.30" )))
147
+
148
+ clear_cache()
149
+ unlink(" results" , recursive = TRUE )
246
150
})
247
151
248
152
test_that(" k for cv , n.bags for bagging can be changed and approx works" , {
0 commit comments