I want my predictions in probabilities between 0 and 1. I already did that in xgboost but I wanna try out Lightgbm too but its outputting solid predictions(that is in integer only). I could do that in XGBoost by setting 'objective' parameter to binary:logistic but in Lightgbm there doesn't seem to be any parameter like that, It only has binary and it is giving output in 0 or 1.
Asked
Active
Viewed 3,507 times
-1
-
in both XGBoost and LightGBM there is a difference between predicted probabilities and labels, labels being integers, which are evaluated as `(probability > threashold).astype(int)` – Mischa Lisovyi Aug 02 '18 at 12:38
-
@MykhailoLisovyi ok, so I want to estimate probability between 0 and 1, so do I need to change source code for that? – vishal tewatia Aug 10 '18 at 15:09
-
You'd need to provide an example; for me, setting objective to 'binary' gives outputs as probabilities. – Ben Reiniger Aug 19 '20 at 20:04
3 Answers
0
To get the class probability between 0 and 1 in lightgbm, you have to use a default value of a parameter "objective" is a regression.
'objective' = 'binary' ( return class label 0 or 1)
'objective' = 'regression' ( return class probability between 0 and 1)

B. Kanani
- 606
- 5
- 11
0
You can do it by setting objective: “multiclass” with num_class: 2 as parameters. The results might not be the same with direct binary classification model yet I can ensure you that there will be no performance loss.
Bonus: As loss metric, you can use “multi_error” or “multi_logloss” or interestingly a combination of both like: metric: “multi_error”, “multi_logloss”

Ugur MULUK
- 446
- 2
- 8
-1
You can use predict(raw_score=True)
If you are using the sklearn API
- You can use objective "binary", just use predict_proba()
instead of predict()

oguz ismail
- 1
- 16
- 47
- 69

fangorn
- 34
- 7