-
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
[python-package] Booster.refit()
segfaults when label only contains 1 class
#6792
Comments
refit()
segfaults when label only contains 1 classBooster.refit()
segfaults when label only contains 1 class
May I work on this issue? |
Sure, thanks! But please note... a solution to this should find the root cause, and might need to fix it in the C/C++ API. We'd want this to be fixed for other interfaces (like the R package) if it is a problem there too. And in your contribution, please add unit tests that would prevent this from being reintroduced in the future. |
Understood, any tips on how to approach this? |
Try to run the code from the description, confirm it fails in the same way on your machine. Then try to figure out where the segfault is happening and why. |
Well that would be a bug too, so you could investigate that. PIm the future, please post code and logs in text, not images, so others can find them from search and so they can more easily be copied. |
I've run the reproducible example a few times and I'm not seeing the segmentation fault on my machine, just the value error. |
Sharing all the logs from when you built LightGBM would be helpful. Maybe this problem is compiler or operating-system specific. Documenting why and where that Value Error happens would be helpful too. One way you can help us here is to narrow down when and why these things happen. |
This is the log from when I ran the example, from what I can tell the Value Error occurs when .refit is called and leaf_preds.shape is used to initialize nrow and ncol, it's only returning one value instead of two. The line number for leaf_preds.shape on my machine is different from where it is in the basic.py file in the Github repository. LightGBM/python-package/lightgbm/basic.py Line 4885 in 81922a7
|
I specifically asked for the logs from when you BUILT LightGBM. These would tell us, for example, the operating system and compiler you used. But....
That suggests to me that you did not build the latest version from source and install it. To work on this problem, you need to do that. |
I installed the latest version of lightgbm through Pypi as documented on the installation guide, am I missing a step? |
Yes, you have to build the project from source if you want to investigate this bug. There are many changes on the All of the installation steps to reproduce the bug are in the description of this issue, including how to install the development version (see "Command(s) you used to install LightGBM" in the description). |
I've been attempting to install lightgbm the way you did after figuring out what you did wrong, but I've hit a snag where I can't run |
Are you using Git for Windows to work with Alternatively, you could:
|
Ok, I'm trying to use Git for Windows now, but it keeps stopping because it says it can't find the command pip at line 184. |
You'll need to install If you have not used You might want to look for other ways to contribute to LightGBM that don't involve building the project from source, like clarifying or expanding the documentation or improving the warnings / error messages. |
Description
Using the Python package, when fitting a binary classification model with only categorical features and using linear trees,
refit()
segfaults iflabel
has only 1 class.Reproducible example
Logs from
refit()
:Training the same model but without
linear_tree=True
,refit()
does not segfault or otherwise raise an exception... it just trains a stub model, as expected.Logs from
refit()
:Tree content:
Environment info
LightGBM version or commit hash: 226e7f7
Command(s) you used to install LightGBM
cmake -B build -S . -DUSE_OPENMP=OFF cmake --build build --target _lightgbm -j4 sh build-python.sh install --precompile
Additional Comments
Fitting a model with a single class is maybe not that useful of a case for LightGBM, but still... LightGBM should never do something that results in process-crashing segmentation fault.
And these sorts of situations can occur unintentionally, for example in AutoML systems where random subsets of training data are selected.
The text was updated successfully, but these errors were encountered: