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

Add support for different prediction types #10

Closed

Conversation

nunosilva800
Copy link
Contributor

@nunosilva800 nunosilva800 commented Dec 12, 2024

Comment on lines +151 to +155
# @param predict_type [Integer] What should be predicted
# - C_API_PREDICT_NORMAL: normal prediction, with transform (if needed);
# - C_API_PREDICT_RAW_SCORE: raw score;
# - C_API_PREDICT_LEAF_INDEX: leaf index;
# - C_API_PREDICT_CONTRIB: feature contributions (SHAP values)
Copy link
Contributor Author

@nunosilva800 nunosilva800 Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a single argument instead of 3 boolean args, like Python API does.

https://lightgbm.readthedocs.io/en/stable/pythonapi/lightgbm.Booster.html#lightgbm.Booster.predict

https://github.com/microsoft/LightGBM/blob/e057ae08e6bf6c6c84f276a127423fb145ca5fdb/python-package/lightgbm/basic.py#L1079-L1081

@ankane
Let me know which you prefer. I don't really see the point of 3 booleans, since they are exclusive...

assert_elements_in_delta [
0.1094902954684793, -0.2810485083947154, 0.26691627597706397, -0.13037702397316747
], shap_values_2
assert_in_delta (0.9933333333834246), ypred_2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why the last value (supposed to be the prediction result) is the same on each row, and why different from expected ypred values in other tests.

@nunosilva800 nunosilva800 marked this pull request as ready for review December 12, 2024 17:02
@ankane ankane closed this in f500d5f Dec 16, 2024
@ankane
Copy link
Owner

ankane commented Dec 16, 2024

Thanks @nunosilva800, merged a version of this in the commit above. I'd prefer to keep the API consistent with Python.

@nunosilva800 nunosilva800 deleted the booster_predict_type branch December 16, 2024 07:46
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

Successfully merging this pull request may close these issues.

2 participants