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] added argument eval_train_metric to lgb.cv() (fixes #4911) #4918

Merged
merged 7 commits into from
Dec 29, 2021
Merged

[R-package] added argument eval_train_metric to lgb.cv() (fixes #4911) #4918

merged 7 commits into from
Dec 29, 2021

Conversation

mayer79
Copy link
Contributor

@mayer79 mayer79 commented Dec 28, 2021

Attempt to solve #4911

If we set eval_train_metric = TRUE in lgb.cv(), then we get output like

[1] "[50]: train's binary_logloss:0.248276+0.00109575 valid's binary_logloss:0.248655+0.00448549"

The resulting object "cvm" contains the information in the record_evals slot and the average training performance of the best round could be found by something like cvm$record_evals$train$binary_logloss$eval[[cvm$best_iter]].

There is no unit test yet, but that does not mean we shouldn't write one.

@jameslamb jameslamb changed the title added argument eval_train_metric [R-package] added argument eval_train_metric to lgb.cv() Dec 28, 2021
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 picking this up!

Please do add a unit test testing this behavior. Let me know if you need help with it.

Please re-generate the documentation.

sh build-cran-package.sh --no-build-vignettes
R CMD INSTALL --with-keep.source ./lightgbm_3.3.1.99.tar.gz
cd R-package
Rscript -e "roxygen2::roxygenize(load = 'installed')"

...to fix issues like the following in CI (e.g. in this build)

Codoc mismatches from documentation object 'lgb.cv':
lgb.cv
  Code: function(params = list(), data, nrounds = 100L, nfold = 3L,
                 label = NULL, weight = NULL, obj = NULL, eval = NULL,
                 verbose = 1L, record = TRUE, eval_freq = 1L, showsd =
                 TRUE, eval_train_metric = FALSE, stratified = TRUE,
                 folds = NULL, init_model = NULL, colnames = NULL,
                 categorical_feature = NULL, early_stopping_rounds =
                 NULL, callbacks = list(), reset_data = FALSE,
                 serializable = TRUE)
  Docs: function(params = list(), data, nrounds = 100L, nfold = 3L,
                 label = NULL, weight = NULL, obj = NULL, eval = NULL,
                 verbose = 1L, record = TRUE, eval_freq = 1L, showsd =
                 TRUE, stratified = TRUE, folds = NULL, init_model =
                 NULL, colnames = NULL, categorical_feature = NULL,
                 early_stopping_rounds = NULL, callbacks = list(),
                 reset_data = FALSE, serializable = TRUE)
  Argument names in code not in docs:
    eval_train_metric
  Mismatches in argument names (first 3):
    Position: 13 Code: eval_train_metric Docs: stratified
    Position: 14 Code: stratified Docs: folds
    Position: 15 Code: folds Docs: init_model

R-package/R/lgb.cv.R Outdated Show resolved Hide resolved
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 very much! The new test looks great! Just one more small suggestion.

R-package/tests/testthat/test_basic.R Outdated Show resolved Hide resolved
Co-authored-by: James Lamb <jaylamb20@gmail.com>
@jameslamb jameslamb self-requested a review December 29, 2021 18:14
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 great, thanks!

@jameslamb jameslamb changed the title [R-package] added argument eval_train_metric to lgb.cv() [R-package] added argument eval_train_metric to lgb.cv() (fixes #4911) Dec 29, 2021
@jameslamb jameslamb merged commit aa647d4 into microsoft:master Dec 29, 2021
@jameslamb
Copy link
Collaborator

Thanks as always for the help @mayer79 !

@mayer79 mayer79 deleted the eval_train_metric branch December 29, 2021 20:12
@mayer79
Copy link
Contributor Author

mayer79 commented Dec 29, 2021

Thanks as always for the help @mayer79 !

Thanks go to you, sir :-)

@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