Skip to content

Commit 86f8a4e

Browse files
authored
revisit docs on model formulas (#1022)
1 parent 8a5b8b3 commit 86f8a4e

18 files changed

+49
-40
lines changed

man/details_boost_tree_xgboost.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_gen_additive_mod_mgcv.Rd

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_mlp_brulee.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_proportional_hazards_glmnet.Rd

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_proportional_hazards_survival.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_surv_reg_survival.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_survival_reg_survival.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rmd/gen_additive_mod_mgcv.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ gen_additive_mod() %>%
6060
The smoothness of the terms will need to be manually specified (e.g., using `s(x, df = 10)`) in the formula. Tuning can be accomplished using the `adjust_deg_free` parameter.
6161

6262

63-
However, when using a workflow, the best approach is to avoid using [workflows::add_formula()] and use [workflows::add_variables()] in conjunction with a model formula:
63+
When using a workflow, pass the _model formula_ to [add_model()]'s `formula` argument, and a simplified _preprocessing formula_ elsewhere.
6464

6565
```{r}
6666
spec <-
@@ -69,13 +69,13 @@ spec <-
6969
set_mode("regression")
7070
7171
workflow() %>%
72-
add_variables(outcomes = c(mpg), predictors = c(wt, gear, cyl, disp)) %>%
7372
add_model(spec, formula = mpg ~ wt + gear + cyl + s(disp, k = 10)) %>%
73+
add_formula(mpg ~ wt + gear + cyl + disp) %>%
7474
fit(data = mtcars) %>%
7575
extract_fit_engine()
7676
```
7777

78-
The reason for this is that [workflows::add_formula()] will try to create the model matrix and fail to find/use `s()`.
78+
To learn more about the differences between these formulas, see [`?model_formula`][parsnip::model_formula].
7979

8080
## Preprocessing requirements
8181

man/rmd/gen_additive_mod_mgcv.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ gen_additive_mod() %>%
9696
The smoothness of the terms will need to be manually specified (e.g., using `s(x, df = 10)`) in the formula. Tuning can be accomplished using the `adjust_deg_free` parameter.
9797

9898

99-
However, when using a workflow, the best approach is to avoid using [workflows::add_formula()] and use [workflows::add_variables()] in conjunction with a model formula:
99+
When using a workflow, pass the _model formula_ to [add_model()]'s `formula` argument, and a simplified _preprocessing formula_ elsewhere.
100100

101101

102102
```r
@@ -106,8 +106,8 @@ spec <-
106106
set_mode("regression")
107107

108108
workflow() %>%
109-
add_variables(outcomes = c(mpg), predictors = c(wt, gear, cyl, disp)) %>%
110109
add_model(spec, formula = mpg ~ wt + gear + cyl + s(disp, k = 10)) %>%
110+
add_formula(mpg ~ wt + gear + cyl + disp) %>%
111111
fit(data = mtcars) %>%
112112
extract_fit_engine()
113113
```
@@ -126,7 +126,7 @@ workflow() %>%
126126
## GCV score: 4.225228
127127
```
128128

129-
The reason for this is that [workflows::add_formula()] will try to create the model matrix and fail to find/use `s()`.
129+
To learn more about the differences between these formulas, see [`?model_formula`][parsnip::model_formula].
130130

131131
## Preprocessing requirements
132132

man/rmd/glmnet-details.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ tidy(fit)
169169
## 4 hp -0.0101 1
170170
## 5 drat 0 1
171171
## 6 wt -2.59 1
172-
## # … with 5 more rows
172+
## # 5 more rows
173173
```
174174

175175
Note that there is a `tidy()` method for `glmnet` objects in the `broom` package. If this is used directly on the underlying `glmnet` object, it returns _all of coefficients on the path_:
@@ -191,7 +191,7 @@ all_tidy_coefs
191191
## 4 (Intercept) 4 24.7 3.89 0.347
192192
## 5 (Intercept) 5 26.0 3.55 0.429
193193
## 6 (Intercept) 6 27.2 3.23 0.497
194-
## # … with 634 more rows
194+
## # 634 more rows
195195
```
196196

197197
```r

0 commit comments

Comments
 (0)