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] remove uses of ... in Predictor constructor #4338

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ Booster <- R6::R6Class(
predleaf = FALSE,
predcontrib = FALSE,
header = FALSE,
reshape = FALSE, ...) {
reshape = FALSE,
...) {

# Check if number of iteration is non existent
if (is.null(num_iteration)) {
Expand All @@ -513,7 +514,11 @@ Booster <- R6::R6Class(
}

# Predict on new data
predictor <- Predictor$new(private$handle, ...)
params <- list(...)
predictor <- Predictor$new(
modelfile = private$handle
, params = params
)
return(
predictor$predict(
data = data
Expand All @@ -531,7 +536,7 @@ Booster <- R6::R6Class(

# Transform into predictor
to_predictor = function() {
return(Predictor$new(private$handle))
return(Predictor$new(modelfile = private$handle))
},

# Used for save
Expand Down
3 changes: 1 addition & 2 deletions R-package/R/lgb.Predictor.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ Predictor <- R6::R6Class(
},

# Initialize will create a starter model
initialize = function(modelfile, ...) {
params <- list(...)
initialize = function(modelfile, params = list()) {
private$params <- lgb.params2str(params = params)
handle <- NULL

Expand Down
2 changes: 1 addition & 1 deletion R-package/R/lgb.train.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ lgb.train <- function(params = list(),

# Check for boosting from a trained model
if (is.character(init_model)) {
predictor <- Predictor$new(init_model)
predictor <- Predictor$new(modelfile = init_model)
} else if (lgb.is.Booster(x = init_model)) {
predictor <- init_model$to_predictor()
}
Expand Down