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

[R-package] predict ignores predict_raw_score #4670

Closed
Tracked by #5153
david-cortes opened this issue Oct 10, 2021 · 2 comments · Fixed by #5122
Closed
Tracked by #5153

[R-package] predict ignores predict_raw_score #4670

david-cortes opened this issue Oct 10, 2021 · 2 comments · Fixed by #5122
Assignees

Comments

@david-cortes
Copy link
Contributor

After fitting a binary classification model, calling predict with predict_raw_score=TRUE or its aliases as explained in the docs will not output the raw score, only a probability as it would without this parameter:

library(lightgbm)
data("agaricus.train")
pool = lgb.Dataset(agaricus.train$data, label=agaricus.train$label)
params = list(
    objective_type="binary",
    force_row_wise=TRUE,
    seed=123
)
model = lgb.train(params, pool, verbose=0)
summary(predict(model, agaricus.train$data, params=list(predict_raw_score=TRUE)))
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.0000201 0.0000212 0.0000232 0.4821127 0.9999774 0.9999774 
summary(predict(model, agaricus.train$data))
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.0000201 0.0000212 0.0000232 0.4821127 0.9999774 0.9999774 
@jameslamb
Copy link
Collaborator

Thanks for raising this! This is an inconsistency we should resolve.

As documented in the R package docs or in ?lightgbm::predict.lgb.Booster, that function has a keyword argument rawscore which you can set to TRUE to get raw scores.

However, we should consider raising warnings on inconsistencies between those keyword arguments and the equivalent core-LightGBM parameters, and clearly document the expectation for which value "wins" when both are supplied.

@jameslamb jameslamb added the bug label Oct 10, 2021
@jameslamb jameslamb self-assigned this Apr 3, 2022
jameslamb added a commit that referenced this issue Apr 24, 2022
…dict() (fixes #4670) (#5122)

* fix predict() params

* [R-package] ensure values in params override keyword arguments to predict() (fixes #4670)

* revert accidentally-introduced unrelated test changes

* Update R-package/tests/testthat/test_Predictor.R

Co-authored-by: José Morales <jose.morales@kavak.com>

* Update R-package/tests/testthat/test_Predictor.R

Co-authored-by: José Morales <jose.morales@kavak.com>

* linting

* remove nammes in shap test

* changes to tests

Co-authored-by: José Morales <jose.morales@kavak.com>
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants