File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -139,8 +139,24 @@ check.custom.obj <- function(params, objective) {
139
139
if (! is.null(params [[' objective' ]]) && ! is.null(objective ))
140
140
stop(" Setting objectives in 'params' and 'objective' at the same time is not allowed" )
141
141
142
- if (! is.null(objective ) && typeof(objective ) != ' closure' )
142
+ if (! is.null(objective ) && typeof(objective ) != ' closure' ) {
143
+ if (is.character(objective )) {
144
+ msg <- paste(
145
+ " Argument 'objective' is only for custom objectives." ,
146
+ " For built-in objectives, pass the objective under 'params'." ,
147
+ sep = " "
148
+ )
149
+ error_on_deprecated <- getOption(" xgboost.strict_mode" , default = FALSE )
150
+ if (error_on_deprecated ) {
151
+ stop(msg )
152
+ } else {
153
+ warning(msg , " This warning will become an error in a future version." )
154
+ }
155
+ params $ objective <- objective
156
+ return (list (params = params , objective = NULL ))
157
+ }
143
158
stop(" 'objective' must be a function" )
159
+ }
144
160
145
161
# handle the case when custom objective function was provided through params
146
162
if (! is.null(params [[' objective' ]]) &&
You can’t perform that action at this time.
0 commit comments