2222# ' }
2323# ' These arguments are converted to their specific names at the
2424# ' time that the model is fit. Other options and argument can be
25- # ' set using the `...` slot . If left to their defaults
25+ # ' set using the `set_engine` function . If left to their defaults
2626# ' here (`NULL`), the values are taken from the underlying model
2727# ' functions. If parameters need to be modified, `update` can be used
2828# ' in lieu of recreating the object from scratch.
4646# ' @param sample_size An number for the number (or proportion) of data that is
4747# ' exposed to the fitting routine. For `xgboost`, the sampling is done at at
4848# ' each iteration while `C5.0` samples once during traning.
49- # ' @param ... Other arguments to pass to the specific engine's
50- # ' model fit function (see the Engine Details section below). This
51- # ' should not include arguments defined by the main parameters to
52- # ' this function. For the `update` function, the ellipses can
53- # ' contain the primary arguments or any others.
5449# ' @details
5550# ' The data given to the function are not saved and are only used
5651# ' to determine the _mode_ of the model. For `boost_tree`, the
6358# ' \item \pkg{Spark}: `"spark"`
6459# ' }
6560# '
66- # ' Main parameter arguments (and those in `...`) can avoid
67- # ' evaluation until the underlying function is executed by wrapping the
68- # ' argument in [rlang::expr()] (e.g. `mtry = expr(floor(sqrt(p)))`).
69- # '
7061# '
7162# ' @section Engine Details:
7263# '
7364# ' Engines may have pre-set default arguments when executing the
74- # ' model fit call. These can be changed by using the `...`
75- # ' argument to pass in the preferred values. For this type of
76- # ' model, the template of the fit calls are:
65+ # ' model fit call. For this type of model, the template of the
66+ # ' fit calls are:
7767# '
7868# ' \pkg{xgboost} classification
7969# '
10999# ' reloaded and reattached to the `parsnip` object.
110100# '
111101# ' @importFrom purrr map_lgl
112- # ' @seealso [varying()], [fit()]
102+ # ' @seealso [varying()], [fit()], [set_engine()]
113103# ' @examples
114104# ' boost_tree(mode = "classification", trees = 20)
115105# ' # Parameters can be represented by a placeholder:
@@ -121,11 +111,7 @@ boost_tree <-
121111 mtry = NULL , trees = NULL , min_n = NULL ,
122112 tree_depth = NULL , learn_rate = NULL ,
123113 loss_reduction = NULL ,
124- sample_size = NULL ,
125- ... ) {
126-
127- others <- enquos(... )
128-
114+ sample_size = NULL ) {
129115 args <- list (
130116 mtry = enquo(mtry ),
131117 trees = enquo(trees ),
@@ -141,10 +127,7 @@ boost_tree <-
141127 paste0(" '" , boost_tree_modes , " '" , collapse = " , " ),
142128 call. = FALSE )
143129
144- no_value <- ! vapply(others , null_value , logical (1 ))
145- others <- others [no_value ]
146-
147- out <- list (args = args , others = others ,
130+ out <- list (args = args , others = NULL ,
148131 mode = mode , method = NULL , engine = NULL )
149132 class(out ) <- make_classes(" boost_tree" )
150133 out
@@ -183,11 +166,7 @@ update.boost_tree <-
183166 mtry = NULL , trees = NULL , min_n = NULL ,
184167 tree_depth = NULL , learn_rate = NULL ,
185168 loss_reduction = NULL , sample_size = NULL ,
186- fresh = FALSE ,
187- ... ) {
188-
189- others <- enquos(... )
190-
169+ fresh = FALSE ) {
191170 args <- list (
192171 mtry = enquo(mtry ),
193172 trees = enquo(trees ),
@@ -209,23 +188,20 @@ update.boost_tree <-
209188 object $ args [names(args )] <- args
210189 }
211190
212- if (length(others ) > 0 ) {
213- if (fresh )
214- object $ others <- others
215- else
216- object $ others [names(others )] <- others
217- }
218-
219191 object
220192 }
221193
222194# ------------------------------------------------------------------------------
223195
224196# ' @export
225- translate.boost_tree <- function (x , engine , ... ) {
197+ translate.boost_tree <- function (x , engine = x $ engine , ... ) {
198+ if (is.null(engine )) {
199+ message(" Used `engine = 'xgboost'` for translation." )
200+ engine <- " xgboost"
201+ }
226202 x <- translate.default(x , engine , ... )
227203
228- if (x $ engine == " spark" ) {
204+ if (engine == " spark" ) {
229205 if (x $ mode == " unknown" )
230206 stop(
231207 " For spark boosted trees models, the mode cannot be 'unknown' " ,
0 commit comments