Unverified Commit f7e39388 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] remove support for '...' in predict() (#4857)

* [R-package] remove support for '...' in predict()

* restore ... in S3 method
parent 76fb0b62
...@@ -493,21 +493,10 @@ Booster <- R6::R6Class( ...@@ -493,21 +493,10 @@ Booster <- R6::R6Class(
predcontrib = FALSE, predcontrib = FALSE,
header = FALSE, header = FALSE,
reshape = FALSE, reshape = FALSE,
params = list(), params = list()) {
...) {
self$restore_handle() 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)) { if (is.null(num_iteration)) {
num_iteration <- self$best_iter num_iteration <- self$best_iter
} }
...@@ -517,7 +506,6 @@ Booster <- R6::R6Class( ...@@ -517,7 +506,6 @@ Booster <- R6::R6Class(
} }
# Predict on new data # Predict on new data
params <- utils::modifyList(params, additional_params)
predictor <- Predictor$new( predictor <- Predictor$new(
modelfile = private$handle modelfile = private$handle
, params = params , params = params
...@@ -765,7 +753,7 @@ Booster <- R6::R6Class( ...@@ -765,7 +753,7 @@ Booster <- R6::R6Class(
#' \href{https://lightgbm.readthedocs.io/en/latest/Parameters.html#predict-parameters}{ #' \href{https://lightgbm.readthedocs.io/en/latest/Parameters.html#predict-parameters}{
#' the "Predict Parameters" section of the documentation} for a list of parameters and #' the "Predict Parameters" section of the documentation} for a list of parameters and
#' valid values. #' 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)}. #' @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 #' For multiclass classification, either a \code{num_class * nrows(data)} vector or
#' a \code{(nrows(data), num_class)} dimension matrix is returned, depending on #' a \code{(nrows(data), num_class)} dimension matrix is returned, depending on
...@@ -829,8 +817,7 @@ predict.lgb.Booster <- function(object, ...@@ -829,8 +817,7 @@ predict.lgb.Booster <- function(object,
warning(paste0( warning(paste0(
"predict.lgb.Booster: Found the following passed through '...': " "predict.lgb.Booster: Found the following passed through '...': "
, paste(names(additional_params), collapse = ", ") , paste(names(additional_params), collapse = ", ")
, ". These will be used, but in future releases of lightgbm, this warning will become an error. " , ". These are ignored. Use argument 'params' instead."
, "Add these to 'params' instead. See ?predict.lgb.Booster for documentation on how to call this function."
)) ))
} }
...@@ -844,7 +831,7 @@ predict.lgb.Booster <- function(object, ...@@ -844,7 +831,7 @@ predict.lgb.Booster <- function(object,
, predcontrib = predcontrib , predcontrib = predcontrib
, header = header , header = header
, reshape = reshape , reshape = reshape
, params = utils::modifyList(params, additional_params) , params = params
) )
) )
} }
......
...@@ -52,7 +52,7 @@ prediction outputs per case.} ...@@ -52,7 +52,7 @@ prediction outputs per case.}
the "Predict Parameters" section of the documentation} for a list of parameters and the "Predict Parameters" section of the documentation} for a list of parameters and
valid values.} valid values.}
\item{...}{Additional prediction parameters. NOTE: deprecated as of v3.3.0. Use \code{params} instead.} \item{...}{ignored}
} }
\value{ \value{
For regression or binary classification, it returns a vector of length \code{nrows(data)}. For regression or binary classification, it returns a vector of length \code{nrows(data)}.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment