-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
first metric only in earlystopping for cli #2172
Conversation
I added the note about that this param is for CLI only and slightly paraphrased description for the consistency with others. |
include/LightGBM/config.h
Outdated
@@ -260,7 +260,8 @@ struct Config { | |||
// desc = ``<= 0`` means disable | |||
int early_stopping_round = 0; | |||
|
|||
// desc = will only use first metric for early stopping if set to ``True`` | |||
// desc = set this to ``true``, if you want to use only the first metric for early stopping | |||
// desc = **Note**: can be used only in CLI version |
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.
Although this parameter is actually used in cli version, there is another parameter with the same name in python/R package. Therefore, I think the note is not needed, as well as the early_stopping_round.
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.
It's a little bit another situation (in Python, at least).
early_stopping_round
is a parameter for train
/cv
, so everything is OK, but first_metric_only
is a parameter for callback.
LightGBM/python-package/lightgbm/callback.py
Line 153 in 2a36917
def early_stopping(stopping_rounds, first_metric_only=False, verbose=True): |
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.
okay, I think the first_metric_only should be in train/cv as well, like the early_stopping_round:
LightGBM/python-package/lightgbm/engine.py
Lines 482 to 483 in 2a36917
if early_stopping_rounds is not None: | |
callbacks.add(callback.early_stopping(early_stopping_rounds, verbose=False)) |
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.
Do you think that we should try to retrieve first_metric_only
from params
and pass to callback?
LightGBM/python-package/lightgbm/engine.py
Lines 183 to 184 in 2a36917
if early_stopping_rounds is not None: | |
callbacks.add(callback.early_stopping(early_stopping_rounds, verbose=bool(verbose_eval))) |
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.
yes, just like the early stopping rounds:
LightGBM/python-package/lightgbm/engine.py
Lines 122 to 126 in 2a36917
for alias in ["early_stopping_round", "early_stopping_rounds", "early_stopping"]: | |
if alias in params and params[alias] is not None: | |
early_stopping_rounds = int(params.pop(alias)) | |
warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias)) | |
break |
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.
Got it! Then I'll create a PR for this and remove my note.
refer #2159 (comment)