'Compute the deviance (= 2 * negative log-likelihood).'

def __call__(self, y, pred, sample_weight=None):

    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)))))
