-
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
[python-package] allow custom weighing in fobj for scikit-learn API (closes #5027) #5211
Conversation
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.
Thank you so much for picking up this issue!
Please consider checking some my minor comments below:
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.
Nice! Thank you very much!
@shiyu1994 Would you like to take a look at this PR as you were a creator of #5027? |
1 similar comment
@jameslamb Please help with a second review. |
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 this! I believe I understand the changes, prior discussion on this PR, and previous discussion in #5207.
It's unfortunate that we have to make the breaking change where providing a callable that takes 3 arguments will now be treated as (y_true, y_pred, weight)
when previous releases treated it as (y_true, y_pred, group)
, since the values in weight
and group
can be similar and therefore code that worked in lightgbm
v3.3.2 could silently start producing incorrect results in v4.0.0.
But I agree that that's worth it in exchange for consistency with the existing interface for scikit-learn eval functions, as @StrikerRUS mentioned in
Since v4.0.0 will contain many breaking changes intended to reduce inconsistencies, and since the project's current state doesn't really support doing a round of deprecation warnings first (e.g. #5133 (review)).
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. |
This removes the automatic weighing for
grad
andhess
when using a custom objective in the scikit-learn API and makes the signature equivalent to the custom eval(y_true, y_pred, weight, group)
.Also adds tests to check that the behavior using the built-in objectives and the custom ones is consistent, i.e. if we give the weights to the dataset/fit using the built-in objectives we get the same results as if we use custom objectives and do the weighing ourselves.
Closes #5027.