This is scikit GradientBoosting's binomial deviance loss function,
def __call__(self, y, pred, sample_weight=None):
"""Compute the deviance (= 2 * negative log-likelihood). """
# logaddexp(0, v) == log(1.0 + exp(v))
pred = pred.ravel()
if sample_weight is None:
return -2.0 * np.mean((y * pred) - np.logaddexp(0.0, pred))
else:
return (-2.0 / sample_weight.sum() *
np.sum(sample_weight * ((y * pred) - np.logaddexp(0.0, pred))))
This loss functions is not similar between class with 0 and class with 1. Can anyone explain how this is considered OK.
For example, with no sample weigth, the loss function for class 1 is
-2(pred - log(1 + exp(pred))
vs for class 0
-2(-log(1+exp(pred))
The plot for these two are not similar in terms of cost. Can anyone help me understand.