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] update parameter 'verbosity' based on keyword arg 'verbose' #4899

Merged
merged 3 commits into from
Dec 23, 2021

Conversation

jameslamb
Copy link
Collaborator

Related to #4667.
Related to #4862.

While investigating #4667, I noticed a small inconsistency in lgb.train() and lgb.cv(). Those functions have a keyword argument verbose and update the parameter verbose in parameters passed down to LGBM_BoosterCreate.

params$verbose <- verbose

params$verbose <- verbose

As a result, if you pass different values for verbosity (in params) and verbose (via keyword arguments), then the Booster's parameters will contain both verbosity and verbose.

Consider this example:

library(lightgbm)
data("agaricus.train")
dtrain <- lightgbm::lgb.Dataset(
    data = agaricus.train$data
    , label = agaricus.train$label
)
bst <- lightgbm::lgb.train(
    params = list(
        num_iterations = 2L
        , verbosity = 1L
    )
    , data = dtrain
    , obj = "binary"
    , verbose = -1L
)
bst$params

$verbosity
[1] 1

$verbose
[1] -1

Note that verbosity is the main parameter recognized by LightGBM (https://lightgbm.readthedocs.io/en/latest/Parameters.html#verbosity) and verbose is an alias for it.

This PR proposes two changes:

  1. Update params$verbosity (the main parameter name, instead of an alias) based on the value of keyword argument verbose
  2. Use internal function lgb.check.wrapper_param() to ensure consistent behavior when processing keyword arguments.

)

# defaults from keyword arguments should be used if not specified in params
invisible(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these uses of invisible(capture.output(...)) suppress log messages from being printed, per #4862

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

Nice improvement!

@StrikerRUS StrikerRUS merged commit cace5bb into master Dec 23, 2021
@StrikerRUS StrikerRUS deleted the fix/params branch December 23, 2021 20:59
@StrikerRUS StrikerRUS mentioned this pull request Jan 6, 2022
13 tasks
@jameslamb jameslamb mentioned this pull request Oct 7, 2022
40 tasks
@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 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants