Skip to content

Commit 2e39ad7

Browse files
committed
final for now
1 parent 85691cb commit 2e39ad7

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

README.Rmd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,30 @@ create_model_spec(
110110
.return_tibble = FALSE
111111
)
112112
```
113+
114+
Now the reason we are here. Let's take a look at the first function for modeling
115+
with `{tidyaml}`, __`fast_regression()`__.
116+
117+
```{r, warning=FALSE, message=FALSE}
118+
library(recipes)
119+
library(dplyr)
120+
121+
rec_obj <- recipe(mpg ~ ., data = mtcars)
122+
frt_tbl <- fast_regression(
123+
.data = mtcars,
124+
.rec_obj = rec_obj,
125+
.parsnip_eng = c("lm","glm","gee"),
126+
.parsnip_fns = "linear_reg"
127+
)
128+
129+
glimpse(frt_tbl)
130+
```
131+
132+
As we see above, one of the models has gracefully failed, thanks in part to the
133+
function `purrr::safely()`, which was used to make what I call __safe_make__ functions.
134+
135+
Let's look at the fitted workflow predictions.
136+
137+
```{r}
138+
frt_tbl$pred_wflw
139+
```

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,75 @@ create_model_spec(
226226
#>
227227
#> Computational engine: cubist
228228
```
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

Comments
 (0)