@@ -226,3 +226,75 @@ create_model_spec(
226
226
# >
227
227
# > Computational engine: cubist
228
228
```
229
+
230
+ Now the reason we are here. Let’s take a look at the first function for
231
+ modeling with ` {tidyaml} ` , ** ` fast_regression() ` ** .
232
+
233
+ ``` r
234
+ library(recipes )
235
+ library(dplyr )
236
+
237
+ rec_obj <- recipe(mpg ~ . , data = mtcars )
238
+ frt_tbl <- fast_regression(
239
+ .data = mtcars ,
240
+ .rec_obj = rec_obj ,
241
+ .parsnip_eng = c(" lm" ," glm" ," gee" ),
242
+ .parsnip_fns = " linear_reg"
243
+ )
244
+
245
+ glimpse(frt_tbl )
246
+ # > Rows: 3
247
+ # > Columns: 8
248
+ # > $ .model_id <int> 1, 2, 3
249
+ # > $ .parsnip_engine <chr> "lm", "gee", "glm"
250
+ # > $ .parsnip_mode <chr> "regression", "regression", "regression"
251
+ # > $ .parsnip_fns <chr> "linear_reg", "linear_reg", "linear_reg"
252
+ # > $ model_spec <list> [~NULL, ~NULL, NULL, regression, TRUE, NULL, lm, TRUE]…
253
+ # > $ wflw <list> [cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb, mp…
254
+ # > $ fitted_wflw <list> [cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb, mp…
255
+ # > $ pred_wflw <list> [<tbl_df[24 x 1]>], "Error - Could not make prediction…
256
+ ```
257
+
258
+ As we see above, one of the models has gracefully failed, thanks in part
259
+ to the function ` purrr::safely() ` , which was used to make what I call
260
+ ** safe_make** functions.
261
+
262
+ Let’s look at the fitted workflow predictions.
263
+
264
+ ``` r
265
+ frt_tbl $ pred_wflw
266
+ # > [[1]]
267
+ # > # A tibble: 24 × 1
268
+ # > .pred
269
+ # > <dbl>
270
+ # > 1 22.2
271
+ # > 2 13.1
272
+ # > 3 15.8
273
+ # > 4 28.5
274
+ # > 5 20.2
275
+ # > 6 11.4
276
+ # > 7 30.0
277
+ # > 8 18.7
278
+ # > 9 31.7
279
+ # > 10 16.4
280
+ # > # … with 14 more rows
281
+ # >
282
+ # > [[2]]
283
+ # > [1] "Error - Could not make predictions"
284
+ # >
285
+ # > [[3]]
286
+ # > # A tibble: 24 × 1
287
+ # > .pred
288
+ # > <dbl>
289
+ # > 1 22.2
290
+ # > 2 13.1
291
+ # > 3 15.8
292
+ # > 4 28.5
293
+ # > 5 20.2
294
+ # > 6 11.4
295
+ # > 7 30.0
296
+ # > 8 18.7
297
+ # > 9 31.7
298
+ # > 10 16.4
299
+ # > # … with 14 more rows
300
+ ```
0 commit comments