-
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] Weights is ignored when customized objective function is used #5027
Comments
Moving the conversation from #4925 (comment) here. This may be intentional because the weights are available in the custom objective function through the training API and not through scikit-learn's but it'd be nice to clarify this. |
I think this is a oversight because one form of custom evaluation function accepts weights in scikit-learn API: LightGBM/python-package/lightgbm/sklearn.py Lines 138 to 141 in 97c8d94
I guess the same can be done for custom objective function. |
Hmm now I'm more confused because for the objective function weights aren't allowed LightGBM/python-package/lightgbm/sklearn.py Lines 105 to 112 in 97c8d94
but for eval they are LightGBM/python-package/lightgbm/sklearn.py Lines 192 to 201 in 97c8d94
|
Yeah, exactly! I'm proposing to allow passing weights for the objective function. |
I think it may be more user friendly to weigh things automatically. I think specifying sample weights either through the |
Highly likely. But what if no?.. There will be no way to unweight them then. I think it's better to not weight automatically anything but allow user to choose weight or not weight. |
I agree with you, it gives the user full control and could enable use cases like #4995, which could be achieved by weighing only the metric but not the grad and hess. So we should remove this then, right? LightGBM/python-package/lightgbm/sklearn.py Lines 115 to 122 in 97c8d94
|
Does that mean, in the example above, we should let the user to weight the gradients in the |
I guess so. |
Shall we open an PR to remove the weighting in sklearn API? |
I'm for it. |
…loses #5027) (#5211) * allow custom weighing in sklearn api * add suggestions from review Co-authored-by: Nikita Titov <[email protected]>
This issue 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. |
Description
Weights are not multiplied to the gradients and hessians from customized objective function in Python API.
Reproducible example
LightGBM version or commit hash:
Version 3.3.2
Command(s) you used to install LightGBM
Install from source
The text was updated successfully, but these errors were encountered: