-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[WIP] Add chosen metric argument to clarify early stopping behaviour #6424
Open
sami-ka
wants to merge
4
commits into
microsoft:master
Choose a base branch
from
sami-ka:modify_early_stopping_metric
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4ce23bd
feat: add chosen_metric attribute in early stopping callback class
sami-ka dbdc17c
feat: add chosen_metric_early_stopping parameter to create early stop…
sami-ka 53698f7
feat: add chosen_metric_early_stopping to the list of parameters
sami-ka 44fcae2
refactor: replace argument name and add chekcs +warning
sami-ka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this some more... I don't think we should add this as a parameter in LightGBM's C API.
Right now, LightGBM (across all its interfaces), has this mix of behaviors:
metric
parameterearly_stopping_rounds > 0
and provide any validation sets, LightGBM will try to perform early stopping based on all metrics and all validation setsfirst_metric_only = true
, in which case LightGBM will perform early stopping on only 1 metric (but still for all validation sets)related: #6360
Two types of behavior rely on that
metric
parameter:We still want to provide the ability to record multiple metrics during training.
In addition, the CLI and C API don't have a concept of "callbacks", so a parameter
metric_name
that only accepts a single metric wouldn't be sufficient for them if they want to perform early stopping on the basis of multiple metrics.We also have to think carefully about what breaking changes (if any) to make to LightGBM's existing behavior of automatically performing early stopping on all metrics if you enable early stopping at all.
I'm not sure what direction to set you on... need to think about this for a few days.
This is has been a quite complicated part of LightGBM's interface, I'd like to simplify it and give people finer control, but also do that in a way that minimizes the number of breaking changes made.
For example, maybe we could turn off the "automatically add the early stopping callback based on
params
" behavior if anylgb.early_stopping
callbacks are passed throughcallbacks
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your explanations, I now also realize all the implications of this change, adjusting the python part with others!
I also understand that being able to specify the
metric_name
in the parameters dict would be preferable, as other early stopping parameters can be specified here as well. However feel free to tell me to undo the changes outside of the Callback class, if it helps to split this in different PRs.My tests with the callback API changes alone have the expected behaviour.
I will try to take a bit more look at the C API and give you my 2cents during the week-end about how the change could be implemented. I don't expect to come up with the solution, but I guess it could help you to take a decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, thanks! I just want to be sure we're respectful of your time and limit how often we ask you to do something and then to undo it.
This is a part of LightGBM (and the Python package) that has to be handled with extreme care. Early stopping is a very important part of training GBDTs, and lots of existing code out in the world relies on the existing behavior.
If you want some more background on that,you might find this discussion useful: #5808