-
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
Custom objective function doesn't produce expected results #4659
Comments
Thanks very much for your interest in LightGBM. Are you able to provide a minimal, reproducible example that maintainers could run, to see if we observe the same behavior? That would include
|
Hello, thanks for your quick answer. I'm using LightGBM 3.2.1, installed using The actual code I have is not trivially separable but I'll try to isolate a self-contained code that can reproduce the issue. In the meantime, please feel free to indicate if by any chance you'd spot any obvious mistake in the custom function, or in the general logic of it. In particular, I've tried to read the |
Thank you very much for the additional information. Without a minimal, reproducible example you're unlikely to get a high-quality answer very quickly, since the lack of such an example greatly increases the effort required for maintainers to answer your question. For example, the behavior of custom objective functions in the Python package is slightly different depending on whether you are using the functional interface (
I do see at least one thing that confuses me, and which would be clarified with a reproducible example. Your code is referencing objects called I noticed that it looks like you double-posted this question to Stack Overflow around the same time that you posted here. Please don't do this. It can lead to duplicate effort. For example, I monitor the I'm also requesting that you not do this because, in my experience, we regularly see double-posting where the poster moves on after getting their answer in one place and does not go back to update the other place. That can lead to dead-ends for people facing the same issue in the future who find the unresolved post from search engines. |
I understand your comment about the double-posting on here and Stack Overflow. I just deleted my question on Stack Overflow for this topic to be kept here. Will post a reproducible example asap. |
If it helps @JivanRoquet or anyone else, I created a quick notebook that shows how to reproduce the results of LightGBM's built-in Poisson objective and evaluation functions via custom functions. The three-step process (calculating first- and second-order derivatives of the objective function, implementing objective and evaluation functions, and then using them with LightGBM's .fit() or .train() API) is described in more detail here. |
This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one. Thank you for taking the time to improve LightGBM! |
This issue has been automatically locked since there has not been any recent activity since it was closed. |
Thank you for making LightGBM available.
Following this example made for XGBoost, I've tried implementing a custom objective function which is, for the time being, aimed at reproducing the built-in
multiclass
objective function. The goal for now is not to be efficient, just to mimic the existingmulticlass
objective function's return values.If I initialise the model with
objective=custom_training_loss
, the eval multiclass loss makes no progress during training.But if I use
objective='multiclass'
the eval multiclass loss behaves as expected:I'm not sure if there's a bug in my NumPy code, or if there is something I didn't get right from what the function is supposed to return, or how it should behave.
The text was updated successfully, but these errors were encountered: