microsoft / LightGBM

A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.
https://lightgbm.readthedocs.io/en/latest/
MIT License
16.73k stars 3.84k forks source link

Gradients calculation doesn't match with probability #28

Closed tks0123456789 closed 8 years ago

tks0123456789 commented 8 years ago

Gradients https://github.com/Microsoft/LightGBM/blob/master/src/objective/binary_objective.hpp#L63-L78 63 const scoret response = -2.0f * label * sigmoid / (1.0f + std::exp(2.0f * label * sigmoid_ * score[i])); 66 hessians[i] = absresponse * (2.0f * sigmoid - abs_response) * label_weight; and line 75, 78 This is derived from logloss func L = -log(1+exp(-2 * label * score)) and prob = 1 / (1+exp(-2score)). But the following prob calcs don't contain 2 \ within exp().

Probability https://github.com/Microsoft/LightGBM/blob/master/src/boosting/gbdt.cpp#L368 368 ret = 1.0 / (1.0 + std::exp(-sigmoid_ * ret));

https://github.com/Microsoft/LightGBM/blob/master/src/metric/binary_metric.hpp#L60-L68 60, 68 scoret prob = 1.0f / (1.0f + std::exp(-sigmoid * score[i]));

So you have two options. you can remove all 2.0f * in Gradients calculation, or you can add 2.0f* within exp() in probability calc.

guolinke commented 8 years ago

Thanks, you are right, have fixed.

github-actions[bot] commented 1 year ago

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.