Skip to content

Commit 639fe1a

Browse files
Move all models' update docs (#479)
* Make new doc file for `update` methods * Move models' `update` docs to centralized page * Also include new survival models * Needed to inherit some params * Update pkgdown site * Update NEWS * Update R/update.R Co-authored-by: Davis Vaughan <davis@rstudio.com> * Updates to `parameters` description Co-authored-by: Davis Vaughan <davis@rstudio.com>
1 parent c7e1010 commit 639fe1a

35 files changed

+400
-583
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
* Re-licensed package from GPL-2 to MIT. See [consent from copyright holders here](https://github.com/tidymodels/parsnip/issues/462).
1414

15+
* Re-organized model documentation for `update` methods (#479).
16+
1517
# parsnip 0.1.5
1618

1719
* An RStudio add-in is available that makes writing multiple `parsnip` model specifications to the source window. It can be accessed via the IDE addin menus or by calling `parsnip_addin()`.

R/boost_tree.R

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
#' reloaded and reattached to the `parsnip` object.
8282
#'
8383
#' @importFrom purrr map_lgl
84-
#' @seealso [fit()], [set_engine()]
84+
#' @seealso [fit()], [set_engine()], [update()]
8585
#' @examples
8686
#' show_engines("boost_tree")
8787
#'
@@ -132,32 +132,8 @@ print.boost_tree <- function(x, ...) {
132132

133133
# ------------------------------------------------------------------------------
134134

135-
#' @export
136-
#' @param object A boosted tree model specification.
137-
#' @param parameters A 1-row tibble or named list with _main_
138-
#' parameters to update. If the individual arguments are used,
139-
#' these will supersede the values in `parameters`. Also, using
140-
#' engine arguments in this object will result in an error.
141-
#' @param ... Not used for `update()`.
142-
#' @param fresh A logical for whether the arguments should be
143-
#' modified in-place of or replaced wholesale.
144-
#' @return An updated model specification.
145-
#' @examples
146-
#' model <- boost_tree(mtry = 10, min_n = 3)
147-
#' model
148-
#' update(model, mtry = 1)
149-
#' update(model, mtry = 1, fresh = TRUE)
150-
#'
151-
#' param_values <- tibble::tibble(mtry = 10, tree_depth = 5)
152-
#'
153-
#' model %>% update(param_values)
154-
#' model %>% update(param_values, mtry = 3)
155-
#'
156-
#' param_values$verbose <- 0
157-
#' # Fails due to engine argument
158-
#' # model %>% update(param_values)
159135
#' @method update boost_tree
160-
#' @rdname boost_tree
136+
#' @rdname parsnip_update
161137
#' @export
162138
update.boost_tree <-
163139
function(object,

R/decision_tree.R

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#' functions. If parameters need to be modified, `update()` can be used
2222
#' in lieu of recreating the object from scratch.
2323
#'
24-
#' @inheritParams boost_tree
2524
#' @param mode A single character string for the type of model.
2625
#' Possible values for this model are "unknown", "regression", or
2726
#' "classification".
@@ -60,7 +59,7 @@
6059
#' reloaded and reattached to the `parsnip` object.
6160
#'
6261
#' @importFrom purrr map_lgl
63-
#' @seealso [fit()]
62+
#' @seealso [fit()], [set_engine()], [update()]
6463
#' @examples
6564
#' show_engines("decision_tree")
6665
#'
@@ -102,16 +101,8 @@ print.decision_tree <- function(x, ...) {
102101

103102
# ------------------------------------------------------------------------------
104103

105-
#' @export
106-
#' @inheritParams update.boost_tree
107-
#' @param object A decision tree model specification.
108-
#' @examples
109-
#' model <- decision_tree(cost_complexity = 10, min_n = 3)
110-
#' model
111-
#' update(model, cost_complexity = 1)
112-
#' update(model, cost_complexity = 1, fresh = TRUE)
113104
#' @method update decision_tree
114-
#' @rdname decision_tree
105+
#' @rdname parsnip_update
115106
#' @export
116107
update.decision_tree <-
117108
function(object,

R/linear_reg.R

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#' here (`NULL`), the values are taken from the underlying model
1717
#' functions. If parameters need to be modified, `update()` can be used
1818
#' in lieu of recreating the object from scratch.
19-
#' @inheritParams boost_tree
2019
#' @param mode A single character string for the type of model.
2120
#' The only possible value for this model is "regression".
2221
#' @param penalty A non-negative number representing the total
@@ -60,7 +59,7 @@
6059
#' separately saved to disk. In a new session, the object can be
6160
#' reloaded and reattached to the `parsnip` object.
6261
#'
63-
#' @seealso [fit()], [set_engine()]
62+
#' @seealso [fit()], [set_engine()], [update()]
6463
#' @examples
6564
#' show_engines("linear_reg")
6665
#'
@@ -121,15 +120,8 @@ translate.linear_reg <- function(x, engine = x$engine, ...) {
121120

122121
# ------------------------------------------------------------------------------
123122

124-
#' @inheritParams update.boost_tree
125-
#' @param object A linear regression model specification.
126-
#' @examples
127-
#' model <- linear_reg(penalty = 10, mixture = 0.1)
128-
#' model
129-
#' update(model, penalty = 1)
130-
#' update(model, penalty = 1, fresh = TRUE)
131123
#' @method update linear_reg
132-
#' @rdname linear_reg
124+
#' @rdname parsnip_update
133125
#' @export
134126
update.linear_reg <-
135127
function(object,

R/logistic_reg.R

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#' here (`NULL`), the values are taken from the underlying model
1717
#' functions. If parameters need to be modified, `update()` can be used
1818
#' in lieu of recreating the object from scratch.
19-
#' @inheritParams boost_tree
2019
#' @param mode A single character string for the type of model.
2120
#' The only possible value for this model is "classification".
2221
#' @param penalty A non-negative number representing the total
@@ -59,7 +58,7 @@
5958
#' separately saved to disk. In a new session, the object can be
6059
#' reloaded and reattached to the `parsnip` object.
6160
#'
62-
#' @seealso [fit()]
61+
#' @seealso [fit()], [set_engine()], [update()]
6362
#' @examples
6463
#' show_engines("logistic_reg")
6564
#'
@@ -144,15 +143,8 @@ translate.logistic_reg <- function(x, engine = x$engine, ...) {
144143

145144
# ------------------------------------------------------------------------------
146145

147-
#' @inheritParams update.boost_tree
148-
#' @param object A logistic regression model specification.
149-
#' @examples
150-
#' model <- logistic_reg(penalty = 10, mixture = 0.1)
151-
#' model
152-
#' update(model, penalty = 1)
153-
#' update(model, penalty = 1, fresh = TRUE)
154146
#' @method update logistic_reg
155-
#' @rdname logistic_reg
147+
#' @rdname parsnip_update
156148
#' @export
157149
update.logistic_reg <-
158150
function(object,

R/mars.R

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#' functions. If parameters need to be modified, `update()` can be used
2323
#' in lieu of recreating the object from scratch.
2424
#'
25-
#' @inheritParams boost_tree
2625
#' @param mode A single character string for the type of model.
2726
#' Possible values for this model are "unknown", "regression", or
2827
#' "classification".
@@ -39,7 +38,7 @@
3938
#' @includeRmd man/rmd/mars.Rmd details
4039
#'
4140
#' @importFrom purrr map_lgl
42-
#' @seealso [fit()]
41+
#' @seealso [fit()], [set_engine()], [update()]
4342
#' @examples
4443
#' show_engines("mars")
4544
#'
@@ -79,16 +78,8 @@ print.mars <- function(x, ...) {
7978

8079
# ------------------------------------------------------------------------------
8180

82-
#' @export
83-
#' @inheritParams update.boost_tree
84-
#' @param object A MARS model specification.
85-
#' @examples
86-
#' model <- mars(num_terms = 10, prune_method = "none")
87-
#' model
88-
#' update(model, num_terms = 1)
89-
#' update(model, num_terms = 1, fresh = TRUE)
9081
#' @method update mars
91-
#' @rdname mars
82+
#' @rdname parsnip_update
9283
#' @export
9384
update.mars <-
9485
function(object,

R/mlp.R

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#' If parameters need to be modified, `update()` can be used
2828
#' in lieu of recreating the object from scratch.
2929
#'
30-
#' @inheritParams boost_tree
3130
#' @param mode A single character string for the type of model.
3231
#' Possible values for this model are "unknown", "regression", or
3332
#' "classification".
@@ -54,7 +53,7 @@
5453
#' @includeRmd man/rmd/mlp.Rmd details
5554
#'
5655
#' @importFrom purrr map_lgl
57-
#' @seealso [fit()]
56+
#' @seealso [fit()], [set_engine()], [update()]
5857
#' @examples
5958
#' show_engines("mlp")
6059
#'
@@ -100,21 +99,8 @@ print.mlp <- function(x, ...) {
10099

101100
# ------------------------------------------------------------------------------
102101

103-
#' Update a Single Layer Neural Network Specification
104-
#'
105-
#' If parameters need to be modified, this function can be used
106-
#' in lieu of recreating the object from scratch.
107-
#'
108-
#' @export
109-
#' @inheritParams update.boost_tree
110-
#' @param object A multilayer perceptron model specification.
111-
#' @examples
112-
#' model <- mlp(hidden_units = 10, dropout = 0.30)
113-
#' model
114-
#' update(model, hidden_units = 2)
115-
#' update(model, hidden_units = 2, fresh = TRUE)
116102
#' @method update mlp
117-
#' @rdname mlp
103+
#' @rdname parsnip_update
118104
#' @export
119105
update.mlp <-
120106
function(object,

R/multinom_reg.R

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#' here (`NULL`), the values are taken from the underlying model
1717
#' functions. If parameters need to be modified, `update()` can be used
1818
#' in lieu of recreating the object from scratch.
19-
#' @inheritParams boost_tree
2019
#' @param mode A single character string for the type of model.
2120
#' The only possible value for this model is "classification".
2221
#' @param penalty A non-negative number representing the total
@@ -54,7 +53,7 @@
5453
#' separately saved to disk. In a new session, the object can be
5554
#' reloaded and reattached to the `parsnip` object.
5655
#'
57-
#' @seealso [fit()]
56+
#' @seealso [fit()], [set_engine()], [update()]
5857
#' @examples
5958
#' show_engines("multinom_reg")
6059
#'
@@ -101,15 +100,8 @@ translate.multinom_reg <- translate.linear_reg
101100

102101
# ------------------------------------------------------------------------------
103102

104-
#' @inheritParams update.boost_tree
105-
#' @param object A multinomial regression model specification.
106-
#' @examples
107-
#' model <- multinom_reg(penalty = 10, mixture = 0.1)
108-
#' model
109-
#' update(model, penalty = 1)
110-
#' update(model, penalty = 1, fresh = TRUE)
111103
#' @method update multinom_reg
112-
#' @rdname multinom_reg
104+
#' @rdname parsnip_update
113105
#' @export
114106
update.multinom_reg <-
115107
function(object,

R/nearest_neighbor.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#'
4949
#' @includeRmd man/rmd/nearest-neighbor.Rmd details
5050
#'
51-
#' @seealso [fit()]
51+
#' @seealso [fit()], [set_engine()], [update()]
5252
#'
5353
#' @examples
5454
#' show_engines("nearest_neighbor")
@@ -90,8 +90,9 @@ print.nearest_neighbor <- function(x, ...) {
9090

9191
# ------------------------------------------------------------------------------
9292

93+
#' @method update nearest_neighbor
9394
#' @export
94-
#' @inheritParams update.boost_tree
95+
#' @rdname parsnip_update
9596
update.nearest_neighbor <- function(object,
9697
parameters = NULL,
9798
neighbors = NULL,

R/proportional_hazards.R

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#' Proportional hazards models include the Cox model.
2525
#' For `proportional_hazards()`, the mode will always be "censored regression".
2626
#'
27+
#' @seealso [fit()], [set_engine()], [update()]
2728
#' @examples
2829
#' show_engines("proportional_hazards")
2930
#'
@@ -62,17 +63,8 @@ print.proportional_hazards <- function(x, ...) {
6263

6364
# ------------------------------------------------------------------------------
6465

65-
#' @param object A proportional hazards model specification.
66-
#' @param ... Not used for `update()`.
67-
#' @param fresh A logical for whether the arguments should be
68-
#' modified in-place of or replaced wholesale.
69-
#' @examples
70-
#' model <- proportional_hazards(penalty = 10, mixture = 0.1)
71-
#' model
72-
#' update(model, penalty = 1)
73-
#' update(model, penalty = 1, fresh = TRUE)
7466
#' @method update proportional_hazards
75-
#' @rdname proportional_hazards
67+
#' @rdname parsnip_update
7668
#' @export
7769
update.proportional_hazards <- function(object,
7870
parameters = NULL,

R/rand_forest.R

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#' functions. If parameters need to be modified, `update()` can be used
2121
#' in lieu of recreating the object from scratch.
2222
#'
23-
#' @inheritParams boost_tree
2423
#' @param mode A single character string for the type of model.
2524
#' Possible values for this model are "unknown", "regression", or
2625
#' "classification".
@@ -54,7 +53,7 @@
5453
#' reloaded and reattached to the `parsnip` object.
5554
#'
5655
#' @importFrom purrr map_lgl
57-
#' @seealso [fit()]
56+
#' @seealso [fit()], [set_engine()], [update()]
5857
#' @examples
5958
#' show_engines("rand_forest")
6059
#'
@@ -96,16 +95,8 @@ print.rand_forest <- function(x, ...) {
9695

9796
# ------------------------------------------------------------------------------
9897

99-
#' @export
100-
#' @inheritParams update.boost_tree
101-
#' @param object A random forest model specification.
102-
#' @examples
103-
#' model <- rand_forest(mtry = 10, min_n = 3)
104-
#' model
105-
#' update(model, mtry = 1)
106-
#' update(model, mtry = 1, fresh = TRUE)
10798
#' @method update rand_forest
108-
#' @rdname rand_forest
99+
#' @rdname parsnip_update
109100
#' @export
110101
update.rand_forest <-
111102
function(object,

R/surv_reg.R

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#' `strata` function cannot be used. To achieve the same effect,
3232
#' the extra parameter roles can be used (as described above).
3333
#'
34-
#' @inheritParams boost_tree
3534
#' @param mode A single character string for the type of model.
3635
#' The only possible value for this model is "regression".
3736
#' @param dist A character string for the outcome distribution. "weibull" is
@@ -47,7 +46,7 @@
4746
#'
4847
#' @includeRmd man/rmd/surv-reg.Rmd details
4948
#'
50-
#' @seealso [fit()], [survival::Surv()]
49+
#' @seealso [fit()], [survival::Surv()], [set_engine()], [update()]
5150
#' @references Jackson, C. (2016). `flexsurv`: A Platform for Parametric Survival
5251
#' Modeling in R. _Journal of Statistical Software_, 70(8), 1 - 33.
5352
#' @examples
@@ -99,19 +98,8 @@ print.surv_reg <- function(x, ...) {
9998

10099
# ------------------------------------------------------------------------------
101100

102-
#' Update a Parametric Survival Regression Specification
103-
#'
104-
#' If parameters need to be modified, this function can be used
105-
#' in lieu of recreating the object from scratch.
106-
#'
107-
#' @inheritParams update.boost_tree
108-
#' @param object A survival regression model specification.
109-
#' @examples
110-
#' model <- surv_reg(dist = "weibull")
111-
#' model
112-
#' update(model, dist = "lnorm")
113101
#' @method update surv_reg
114-
#' @rdname surv_reg
102+
#' @rdname parsnip_update
115103
#' @export
116104
update.surv_reg <- function(object, parameters = NULL, dist = NULL, fresh = FALSE, ...) {
117105

0 commit comments

Comments
 (0)