LightGBM
LightGBM copied to clipboard
[cpp, cli] How do I get the Prediction Probability Score from the c++ api (and CLI)
Summary
Hello,
How can I compute the class probability score from the scores predictions?
Thanks for your help
Wil
Motivation
I need to know if the selected class predicted (argmax) has a probablility of 90% or if it is 51%? How can I transform the raw or none raw scores to classes probabilities.
As you can see in the following screenshot, the 1st class is predicted (as it is 0.99819299999937761>>0.0018070000006223936 => ~1 >> ~0). But what is the probability of this prediction? All the score values are either 0.998... or 0.001.... (softmax)
Description
I'm calling c++ functions like LGBM_BoosterPredictForMats from a c# program. I get the raw scores (predict_raw_score=True) or the none raw score (softmax for mutliclass with predict_raw_score=False) from c++ and the CLI but I can not find the probability?
My LightGBM config has the following
objective=multiclass
metric=multi_error
boosting_type=gbdt
num_class=2
I noticed the sckit-learn implementation has a predict_proba function already but it doesn't seem to do much?
elif self._n_classes > 2 or raw_score or pred_leaf or pred_contrib: # type: ignore [operator]
return result
else:
return np.vstack((1.0 - result, result)).transpose()
It will be a good addition to have the class prediction probability for c++, cli and python.
References
Bonus: nice article about Prediction intervals explained: A LightGBM tutorial
Hello @jameslamb ,
I'm looking for something like dtreeviz that returns the tree with probabilities for each leafs (qty and probablility) Dtreeviz can't handle huge csv or bin files, Python won't be able to handle it or very slowly.
m2cgen is insterresting.
Is there some c++ api I can call to get those probabilities with the tree? Or may be a way to get the probability of a prediction? or to add those probabilities and quantities to the CLI when 'task = prediction' is use?
Thanks -w