File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -345,17 +345,15 @@ xgb_train <- function(
345345 arg_list $ num_class <- num_class
346346 }
347347
348- if (! is.null(others $ objective )) {
349- arg_list $ objective <- others $ objective
350- others $ objective <- NULL
351- }
352- if (! is.null(others $ eval_metric )) {
353- arg_list $ eval_metric <- others $ eval_metric
354- others $ eval_metric <- NULL
355- }
356- if (! is.null(others $ nthread )) {
357- arg_list $ nthread <- others $ nthread
358- others $ nthread <- NULL
348+ param_names <- names(formals(xgboost :: xgb.params ))
349+
350+ if (any(param_names %in% names(others ))) {
351+ elements <- param_names [param_names %in% names(others )]
352+
353+ for (element in elements ) {
354+ arg_list [[element ]] <- others [[element ]]
355+ others [[element ]] <- NULL
356+ }
359357 }
360358
361359 if (is.null(arg_list $ objective )) {
You can’t perform that action at this time.
0 commit comments