@@ -148,6 +148,10 @@ print.boost_tree <- function(x, ...) {
148148
149149# ' @export
150150# ' @param object A boosted tree model specification.
151+ # ' @param parameters A 1-row tibble or named list with _main_
152+ # ' parameters to update. If the individual arguments are used,
153+ # ' these will supersede the values in `parameters`. Also, using
154+ # ' engine arguments in this object will result in an error.
151155# ' @param ... Not used for `update()`.
152156# ' @param fresh A logical for whether the arguments should be
153157# ' modified in-place of or replaced wholesale.
@@ -157,17 +161,31 @@ print.boost_tree <- function(x, ...) {
157161# ' model
158162# ' update(model, mtry = 1)
159163# ' update(model, mtry = 1, fresh = TRUE)
164+ # '
165+ # ' param_values <- tibble::tibble(mtry = 10, tree_depth = 5)
166+ # '
167+ # ' model %>% update(param_values)
168+ # ' model %>% update(param_values, mtry = 3)
169+ # '
170+ # ' param_values$verbose <- 0
171+ # ' # Fails due to engine argument
172+ # ' # model %>% update(param_values)
160173# ' @method update boost_tree
161174# ' @rdname boost_tree
162175# ' @export
163176update.boost_tree <-
164177 function (object ,
178+ parameters = NULL ,
165179 mtry = NULL , trees = NULL , min_n = NULL ,
166180 tree_depth = NULL , learn_rate = NULL ,
167181 loss_reduction = NULL , sample_size = NULL ,
168182 fresh = FALSE , ... ) {
169183 update_dot_check(... )
170184
185+ if (! is.null(parameters )) {
186+ parameters <- check_final_param(parameters )
187+ }
188+
171189 args <- list (
172190 mtry = enquo(mtry ),
173191 trees = enquo(trees ),
@@ -178,6 +196,8 @@ update.boost_tree <-
178196 sample_size = enquo(sample_size )
179197 )
180198
199+ args <- update_main_parameters(args , parameters )
200+
181201 # TODO make these blocks into a function and document well
182202 if (fresh ) {
183203 object $ args <- args
0 commit comments