Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-package] Promote objective and init_score to top-level arguments in lightgbm() #4976

Merged
merged 12 commits into from
Feb 23, 2022
Prev Previous commit
Next Next commit
comments
  • Loading branch information
david-cortes committed Feb 16, 2022
commit f18fdb80b43347b9dde768e980233c93f657d19e
14 changes: 2 additions & 12 deletions R-package/R/lightgbm.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ NULL
#' @inheritParams lgb_shared_params
#' @param label Vector of labels, used if \code{data} is not an \code{\link{lgb.Dataset}}
#' @param weight vector of response values. If not NULL, will set to dataset
#' @param save_name File name to use when writing the trained model to disk. Should end in ".model".
#' If passing `NULL`, will not save the trained model to disk.
#' @param init_score initial score is the base prediction lightgbm will boost from
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
#' @param objective Optimization objective (e.g. `"regression"`, `"binary"`, etc.).
#' For a list of accepted objectives, see
#' \href{https://lightgbm.readthedocs.io/en/latest/Parameters.html}{
#' the "Parameters" section of the documentation}.
#' @param save_name File name to use when writing the trained model to disk. Should end in ".model".
#' If passing `NULL`, will not save the trained model to disk.
#' @param ... Additional arguments passed to \code{\link{lgb.train}}. For example
#' \itemize{
#' \item{\code{valids}: a list of \code{lgb.Dataset} objects, used for validation}
Expand Down Expand Up @@ -146,16 +146,6 @@ lightgbm <- function(data,
dtrain <- lgb.Dataset(data = data, label = label, weight = weight, init_score = init_score)
}

if (length(intersect(names(params), .PARAMETER_ALIASES()[["objective"]]))) {
obj_names <- .PARAMETER_ALIASES()[["objective"]]
for (obj_name in obj_names) {
if (!is.null(params[[obj_name]])) {
objective <- params[[obj_name]]
break
}
}
}

train_args <- list(
"params" = params
, "data" = dtrain
Expand Down