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] Updated lgb.Booster.R with keyword arguments #3496

Merged
merged 31 commits into from Oct 30, 2020

Conversation

Pey-crypto
Copy link
Contributor

@Pey-crypto Pey-crypto commented Oct 28, 2020

-I am facing problems while generating the docs
Little help please
#3390

-I am facing problems while generating the docs
Little help please
@ghost
Copy link

ghost commented Oct 28, 2020

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for taking the time to contribute to {lightgbm}!

There are other function calls in lgb.Booster.R that also should be using keyword arguments.

Can you please add keyword arguments to these calls in this file?

  • lgb.check.r6.class()
  • lgb.params2str()
  • private$inner_eval()
  • lgb.call.return.str()
  • predictor$predict()
  • Predictor$new()
  • self$save_model_to_string()
  • object$predict()
  • booster$save_model()
  • booster$dump_model()

Once you've made these changes, I can re-generate the documentation and push it to this pull request.

@@ -335,7 +335,7 @@ Booster <- R6::R6Class(

lower_bound <- 0.0
lgb.call(
"LGBM_BoosterGetLowerBoundValue_R"
fun_name="LGBM_BoosterGetLowerBoundValue_R"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fun_name="LGBM_BoosterGetLowerBoundValue_R"
fun_name = "LGBM_BoosterGetLowerBoundValue_R"

Can you please put a space between the argument name and value for all of these cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay..will be done soon

@jameslamb jameslamb changed the title Updated lgb.Booster.R with keyword arguments [R-package] Updated lgb.Booster.R with keyword arguments Oct 28, 2020
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! I left a few small suggestions

Comment on lines 390 to 393
private$inner_eval(
name = name,
data_idx = data_idx,
feval = feval)
Copy link
Collaborator

@jameslamb jameslamb Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private$inner_eval(
name = name,
data_idx = data_idx,
feval = feval)
private$inner_eval(
data_name = name
, data_idx = data_idx
, feval = feval
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like I mentioned in #3391 , could you please use comma-first style when breaking up lines?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think accepting this and the other suggestions will fix the test failures on GitHub Actions. The right keyword argument here is data_name, not name

Comment on lines 502 to 510
predictor$predict(
data = data,
start_iteration = start_iteration,
num_iteration = num_iteration,
rawscore = rawscore,
predleaf = predleaf,
predcontrib = predcontrib,
header = header,
reshape = reshape)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
predictor$predict(
data = data,
start_iteration = start_iteration,
num_iteration = num_iteration,
rawscore = rawscore,
predleaf = predleaf,
predcontrib = predcontrib,
header = header,
reshape = reshape)
predictor$predict(
data = data
, start_iteration = start_iteration
, num_iteration = num_iteration
, rawscore = rawscore
, predleaf = predleaf
, predcontrib = predcontrib
, header = header
, reshape = reshape
)

Comment on lines 887 to 889
invisible(booster$save_model(
filename = filename,
num_iterations = num_iteration))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
invisible(booster$save_model(
filename = filename,
num_iterations = num_iteration))
invisible(booster$save_model(
filename = filename
, num_iteration = num_iteration
))

Comment on lines 502 to 511
predictor$predict(
data = data,
start_iteration = start_iteration,
num_iteration = num_iteration,
rawscore = rawscore,
predleaf = predleaf,
predcontrib = predcontrib,
header = header,
reshape = reshape
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
predictor$predict(
data = data,
start_iteration = start_iteration,
num_iteration = num_iteration,
rawscore = rawscore,
predleaf = predleaf,
predcontrib = predcontrib,
header = header,
reshape = reshape
)
predictor$predict(
data = data
, start_iteration = start_iteration
, num_iteration = num_iteration
, rawscore = rawscore
, predleaf = predleaf
, predcontrib = predcontrib
, header = header
, reshape = reshape
)

invisible(booster$save_model(filename, num_iteration))
invisible(booster$save_model(
filename = filename
, num_iterations = num_iteration))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, num_iterations = num_iteration))
, num_iterations = num_iteration
))

, predcontrib
, header
, reshape
data = data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = data
data = data

private$inner_eval(
data_name = name
, data_idx = data_idx
, feval = feval)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, feval = feval)
, feval = feval
)

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for all of the requested style changes. If you just click on the suggestions in the browser instead of committing them yourself, it might be easier

R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
Pey-crypto and others added 3 commits October 29, 2020 07:31
Co-authored-by: James Lamb <jaylamb20@gmail.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
@jameslamb jameslamb self-requested a review October 29, 2020 05:24
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the efforts so far! Please see my suggested changes.

I'll review again once this PR also adds the keywords args for these:

  • self$save_model_to_string()
  • lgb.check.r6.class()
  • Predictor$new()

R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
Co-authored-by: James Lamb <jaylamb20@gmail.com>
@jameslamb jameslamb self-requested a review October 29, 2020 17:01
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good so far! But you are still missing these:

  • self$save_model_to_string()
  • lgb.check.r6.class()
  • Predictor$new()

#3496 (review)

If you're struggling with them, please let me know and I'd be happy to help!

@Pey-crypto
Copy link
Contributor Author

Not sure about these
-Predictor$new
-self$save_model_to_string

R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
@jameslamb
Copy link
Collaborator

Not sure about these
-Predictor$new
-self$save_model_to_string

no problem! You can skip these, I will do them in a separate PR.

Pey-crypto and others added 4 commits October 30, 2020 21:54
Co-authored-by: James Lamb <jaylamb20@gmail.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
@@ -216,7 +216,7 @@ Booster <- R6::R6Class(
if (!is.null(train_set)) {

# Check if training set is lgb.Dataset
if (!lgb.check.r6.class(train_set, "lgb.Dataset")) {
if (!lgb.check.r6.class(object = train_set, name = "lgb.Dataset"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!lgb.check.r6.class(object = train_set, name = "lgb.Dataset"))
if (!lgb.check.r6.class(object = train_set, name = "lgb.Dataset")) {

It looks like this { was lost, and the lines are no longer aligned.

@@ -346,7 +346,7 @@ Booster <- R6::R6Class(
eval = function(data, name, feval = NULL) {

# Check if dataset is lgb.Dataset
if (!lgb.check.r6.class(data, "lgb.Dataset")) {
if (!lgb.check.r6.class(object = data, name = "lgb.Dataset"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!lgb.check.r6.class(object = data, name = "lgb.Dataset"))
if (!lgb.check.r6.class(object = data, name = "lgb.Dataset")) {

It looks like the { was lost

@@ -149,7 +149,7 @@ Booster <- R6::R6Class(
add_valid = function(data, name) {

# Check if data is lgb.Dataset
if (!lgb.check.r6.class(data, "lgb.Dataset")) {
if (!(lgb.Dataset = lgb.check.r6.class(data, "lgb.Dataset"))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is still incorrect. Please accept this suggestion in your browser.

Suggested change
if (!(lgb.Dataset = lgb.check.r6.class(data, "lgb.Dataset"))) {
if (!lgb.check.r6.class(object = data, name = "lgb.Dataset")) {

R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
Co-authored-by: James Lamb <jaylamb20@gmail.com>
@jameslamb jameslamb self-requested a review October 30, 2020 17:21
R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
Pey-crypto and others added 3 commits October 30, 2020 22:55
Co-authored-by: James Lamb <jaylamb20@gmail.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your time and efforts! I will merge this once the builds are done.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants