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] avoid unnecessary computation of std deviations in lgb.cv() #4360

Merged
merged 3 commits into from
Jun 12, 2021

Conversation

jameslamb
Copy link
Collaborator

lgb.cv() in the R package performs k-fold cross-validation, and can optionally compute the standard deviation of evaluation metrics across all folds. This option is controlled by the argument showsd (default TRUE).

Today, even when showsd = FALSE, an internal function called by lgb.cv() still calculates error standard deviations and then lgb.cv() just ignores them.

if (showsd) {
env$eval_err_list <- merged_msg$eval_err_list
}

This PR proposes a fix that avoids this unnecessary work, which should slightly speed up lgb.cv() for users who are not interested in the standard deviation of error estimates. It also introduces a test confirming that the output format of lgb.cv() changes based on the value of the showsd argument.

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 catch! LGTM!

@StrikerRUS StrikerRUS merged commit f0bca1a into master Jun 12, 2021
@StrikerRUS StrikerRUS deleted the r/lgb-cv-showsd branch June 12, 2021 15:43
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants