Skip to content
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

Missing feature_name method #4

Closed
jsuchal opened this issue May 14, 2021 · 3 comments
Closed

Missing feature_name method #4

jsuchal opened this issue May 14, 2021 · 3 comments

Comments

@jsuchal
Copy link

jsuchal commented May 14, 2021

We are using this library, but seems like when we load model from file we cannot access the feature names.

In our setup we have a features repository that loads actual data for a model based on feature names, so we have to store the feature names elsewhere. However looking into https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.Booster.html#lightgbm.Booster.feature_name and the saved model file, the feature names are already stored in the model, we are probably only missing a wrapper for native method.

I am not very familiar with FFI so if you have any pointers how to add this I am willing to do a PR on this.

Awesome work on this library wrapper so far!

@ankane ankane closed this as completed in 9f87b99 May 14, 2021
@ankane
Copy link
Owner

ankane commented May 14, 2021

Hey @jsuchal, thanks for reporting! Added in the commit above. This was very similar to the feature_names method for datasets, but the general approach for adding new methods is to find it in the C API header, attach it in lib/lightgbm/ffi.rb, and then add it to the Ruby class.

@StrikerRUS
Copy link

Hey @ankane ! Just want let you know that it is possible to not be limited with 255-length (or any other value) buffer size. It is possible to achieve by repeating the call of C API function in case of returned value in out_buffer_len was larger than buffer_len. Just the same as in model_to_string()
https://github.com/ankane/lightgbm/blob/ba58e984c5e6d80a9b0d9b8b9789abef0c3d2259/lib/lightgbm/booster.rb#L105-L108

Please refer to microsoft/LightGBM#4293.

ankane added a commit that referenced this issue May 15, 2021
@ankane
Copy link
Owner

ankane commented May 15, 2021

Thanks @StrikerRUS! Fixed in b5b3e19 (and fixed eval_names in a follow up commit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants