Skip to content

Conversation

serkor1
Copy link
Contributor

@serkor1 serkor1 commented Aug 19, 2024

Fixes #6612

  • Fix: The associated functions have been fixed by adding a nested if-statement that only triggers if the dart-booster is specified with early_stopping_rounds != NULL.

  • Unittests: The unit-test in test_parameters.R have been rewritten in the following way

    • The lightgbm()-test have had a expect_no_warning()-clause added if the model is correctly specified.

    • A new unittest have been created that checks wether lgb.cv() throws a warning errorneously.

This commit closes #6612. 🔧

@serkor1
Copy link
Contributor Author

serkor1 commented Aug 19, 2024

@microsoft-github-policy-service agree

@jameslamb jameslamb changed the title Update test_parameters.R, lgb.cv.R and lgb.train.R (Issue https://github.com/microsoft/LightGBM/issues/6612) [R-package] only warn about early stopping and DART boosting being incompatible if early stopping was requested Aug 19, 2024
* Issue: When using the 'dart'-booster, the lgb.cv()- and lgb.train()-function would trow a warning regardless of the specified model. See issue #6612

* Fix: The associated functions have been fixed by adding a nested if-statement that only triggers if the dart-booster is specified with early_stopping_rounds != NULL.

* Unittests: The unit-test in test_parameters.R have been rewritten in the following way

	* The lightgbm()-test have had a expect_no_warning()-clause added if the model is correctly specified.

	* A new unittest have been created that checks wether lgb.cv() throws a warning errorneously.

This commit closes #6612. 🔧
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 so much!

I've left some suggestions.

Other notes

If you push additional commits, please don't force-push. All commits here are merged into 1 when a pull request is merged, so force-pushing is unnecessary.

In the future when you contribute here (or in any open source project on GitHub), don't use the target branch (in this case master) on your fork. That makes it more difficult for maintainers to collaborate with you and makes it hard to keep your fork up to date with the upstream repo as it changes. Next time, create a separate branch on your fork, e.g. git checkout -b fix/r-dart-warning.

@jameslamb
Copy link
Collaborator

regarding this comment: #6612 (comment)

I am running into the following R CMD check-issue: Error: could not find function "expect_no_warning" on Windows R 3.6.X

I guess you're referring to https://github.com/microsoft/LightGBM/actions/runs/10455058311/job/28949296216?pr=6619? In the future, if you're referring to something we could observe by clicking links, please share those links in your comment.

There (r-package (windows-latest, MINGW, R 3.6, cmake) job), I see the following:

  -- 2. Error (test_parameters.R:168:7): lgb.cv() should only warn if you use 'dar

  Error: could not find function "expect_no_warning"

Maybe the version of {testthat} getting installed there is too old, I'm not sure. You could try looking into the version being installed and try to figure out when expect_no_warning() was added to {testthat}.

Alternatively, you could change from expect_no_warning() to expect_silent(), which I know has been in {testthat} for many years.

serkor1 and others added 3 commits August 19, 2024 16:44
* expect_no_warning() can't be found on R 3.6.0, so an attempt
with expect_silent() will be made.
* Added spaces after if-statements in lgb.cv() and lgb.train()
* Reduced the character length of unittests to 120 characters
@serkor1 serkor1 marked this pull request as ready for review August 19, 2024 16:25
@serkor1
Copy link
Contributor Author

serkor1 commented Aug 19, 2024

Hi @jameslamb,

It took a while to finalize this PR - for some reason I couldn't get the testing environment up and running locally. In any case, I have used expect_silent() which works on Windows and other OS's too - so that was a good idea!

The main difference from your initial review is that I have shortened the description on the unittests as {lintr} gave me an error on the line length. This can be seen in 2a866e8.

I thought this would be an easy and fast fix, so I didn't consider creating a new branch. I am sorry for this - I will never do stuff on main anymore, I promise 🤞

And thank you so much for all your feedback on this PR.

Best,

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.

My only other suggestions after reviewing again were minor style things that are all personal preference, so I just pushed a commit directly changing those. We'll merge this once CI passes.

Thanks so much for the help! We appreciate the report and you being willing to come contribute. We'd be happy to have you come back and contribute again any time 😊

@jameslamb jameslamb merged commit 5fa615b into microsoft:master Aug 21, 2024
44 checks passed
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 28, 2025
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.

[R-package] [BUG] Using lgb.train() with booster = "dart" gives warning regardless of early_stopping_rounds value
2 participants