Skip to content

Commit

Permalink
[R-package] remove support for '...' in predict() (#4857)
Browse files Browse the repository at this point in the history
* [R-package] remove support for '...' in predict()

* restore ... in S3 method
  • Loading branch information
jameslamb authored Dec 6, 2021
1 parent 76fb0b6 commit f7e3938
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
21 changes: 4 additions & 17 deletions R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -493,21 +493,10 @@ Booster <- R6::R6Class(
predcontrib = FALSE,
header = FALSE,
reshape = FALSE,
params = list(),
...) {
params = list()) {

self$restore_handle()

additional_params <- list(...)
if (length(additional_params) > 0L) {
warning(paste0(
"Booster$predict(): Found the following passed through '...': "
, paste(names(additional_params), collapse = ", ")
, ". These will be used, but in future releases of lightgbm, this warning will become an error. "
, "Add these to 'params' instead. See ?predict.lgb.Booster for documentation on how to call this function."
))
}

if (is.null(num_iteration)) {
num_iteration <- self$best_iter
}
Expand All @@ -517,7 +506,6 @@ Booster <- R6::R6Class(
}

# Predict on new data
params <- utils::modifyList(params, additional_params)
predictor <- Predictor$new(
modelfile = private$handle
, params = params
Expand Down Expand Up @@ -765,7 +753,7 @@ Booster <- R6::R6Class(
#' \href{https://lightgbm.readthedocs.io/en/latest/Parameters.html#predict-parameters}{
#' the "Predict Parameters" section of the documentation} for a list of parameters and
#' valid values.
#' @param ... Additional prediction parameters. NOTE: deprecated as of v3.3.0. Use \code{params} instead.
#' @param ... ignored
#' @return For regression or binary classification, it returns a vector of length \code{nrows(data)}.
#' For multiclass classification, either a \code{num_class * nrows(data)} vector or
#' a \code{(nrows(data), num_class)} dimension matrix is returned, depending on
Expand Down Expand Up @@ -829,8 +817,7 @@ predict.lgb.Booster <- function(object,
warning(paste0(
"predict.lgb.Booster: Found the following passed through '...': "
, paste(names(additional_params), collapse = ", ")
, ". These will be used, but in future releases of lightgbm, this warning will become an error. "
, "Add these to 'params' instead. See ?predict.lgb.Booster for documentation on how to call this function."
, ". These are ignored. Use argument 'params' instead."
))
}

Expand All @@ -844,7 +831,7 @@ predict.lgb.Booster <- function(object,
, predcontrib = predcontrib
, header = header
, reshape = reshape
, params = utils::modifyList(params, additional_params)
, params = params
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion R-package/man/predict.lgb.Booster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f7e3938

Please sign in to comment.