Skip to content

[python-package] allow use of early_stopping_round<=0 to turn off early stopping (fixes #6401) - #6406

Merged
jameslamb merged 10 commits into
lightgbm-org:masterfrom
ddelzell:bugfix/early-stopping-param
Apr 20, 2024
Merged

jameslamb merged 10 commits into
lightgbm-org:masterfrom
ddelzell:bugfix/early-stopping-param

Conversation

@ddelzell

@ddelzell ddelzell commented Apr 3, 2024 •

Copy link
Copy Markdown
Contributor

Fixes #6401

The early stopping callback was instantiated if early_stopping_round was found in the parameter list, even its values was <=0 (which should disable early stopping). The code was modified to only instantiate the early stopping callback if early_stopping_round was both an integer and >0.

Various error messages were updated and unit tests were added.

@ddelzell

ddelzell commented Apr 3, 2024

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Grubhub"

@jameslamb jameslamb added the fix label Apr 3, 2024
@jameslamb

Copy link
Copy Markdown
Member

Thanks! I've added the statement "fixes #6401" to the description. In case you're not familiar with GitHub... that's helpful for 2 reasons:

  1. it means [python-package] Early stopping callback added when early_stopping_round = 0Β #6401 will automatically be closed when we merge this PR
  2. it means that anyone finding [python-package] Early stopping callback added when early_stopping_round = 0Β #6401 from search will see a link back to this PR
Screenshot 2024-04-03 at 2 32 57β€―PM

More details on that: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue

@ddelzell

ddelzell commented Apr 3, 2024

Copy link
Copy Markdown
Contributor Author

Ah, looks like I forgot to run some linting pre-commit hooks? I can try to fix those. Also, we typically rebase to one commit in our PRs as we make changes. Do you have any problem with that?

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks so much for doing this! I left one comment for you to consider. Will try to provide a more thorough review later.

Comment thread python-package/lightgbm/engine.py Resolved
@jameslamb

Copy link
Copy Markdown
Member

Ah, looks like I forgot to run some linting pre-commit hooks? I can try to fix those

Yep. You can do this from the root of the repo to run them.

pip install pre-commit
pre-commit run --all-files

we typically rebase to one commit in our PRs as we make changes. Do you have any problem with that?

We squash all commits into 1 when merging here, so we end up with 1 commit per PR. Check this out: https://github.com/microsoft/LightGBM/commits/master/

Because of that:

  • you could push 1 or 10 or 100 commits to this PR and it won't be a problem
  • you don't need to worry about commit messages being useful... only the PR title will be used as a commit message when this is merged

So please don't rebase and force-push here. It's useful for reviewers to be able to see the individual changes being made in response to review comments, and all the CI logs are tied to commits so it's useful to be able to compare consecutive CI runs.

@jameslamb jameslamb changed the title Remove early stopping callback addition when stopping_rounds <=0 [python-package] allow use of early_stopping_round<=0 to turn off early stopping Apr 3, 2024
@ddelzell
ddelzell requested a review from jameslamb April 4, 2024 17:24

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks very much for this! The tests look great, I just left some small suggestions. This is pretty close, and we'll get it into the next release.

Comment thread python-package/lightgbm/callback.py Resolved
Comment thread python-package/lightgbm/callback.py Resolved
@ddelzell
ddelzell requested a review from jameslamb April 5, 2024 17:46
@jameslamb
jameslamb marked this pull request as ready for review April 10, 2024 13:37
@jameslamb

Copy link
Copy Markdown
Member

Thanks for the changes!

I've updated this to the latest state of the master branch and converted it from "draft" to "ready for review", to pull in some fixes to CI that were preventing a lot of the Python tests from running (#6407). I'll provide another review in a bit.

Comment thread python-package/lightgbm/callback.py Resolved
Comment thread python-package/lightgbm/callback.py Resolved
@jameslamb jameslamb changed the title [python-package] allow use of early_stopping_round<=0 to turn off early stopping [python-package] allow use of early_stopping_round<=0 to turn off early stopping (fixes #6401) Apr 20, 2024
@jameslamb
jameslamb self-requested a review April 20, 2024 02:14

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks very much, we'd love to have you come back and contribute again in the future!

@jameslamb
jameslamb merged commit 1ce2357 into lightgbm-org:master Apr 20, 2024
@ddelzell

Copy link
Copy Markdown
Contributor Author

Thanks, James! Great process, I learned a lot and your reviews were incredibly thorough.

@ddelzell

Copy link
Copy Markdown
Contributor Author

@jameslamb Do you know when the next release is scheduled to be?

@jameslamb

Copy link
Copy Markdown
Member

We're hoping to do one within the next month... but we're battling severe issues in CI right now 😭 (#6425).

@ddelzell

Copy link
Copy Markdown
Contributor Author

OH NO. Thank you for the reply, that's helpful to know.

@github-actions

github-actions Bot commented May 1, 2025

Copy link
Copy Markdown
Contributor

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 May 1, 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.

[python-package] Early stopping callback added when early_stopping_round = 0

3 participants