We are currently using XGBoost model with Tweedie loss for solving a regression problem which works very good, now I wanted to move our model to Keras and experience with neural networks, do anybody know how I can implement Tweedie loss for Keras? I only care about the instance when p=1.5 which gives us the best result in XGBoost.



I end up implementing something like this:

def tweedieloss(y_true, y_pred):
    dev = 2 * (K.pow(y_true, 2-p)/((1-p) * (2-p)) -
                   y_true * K.pow(y_pred, 1-p)/(1-p) +
                   K.pow(y_pred, 2-p)/(2-p))
    return K.mean(dev)

which I don't know how right it is, for now it seems to be working.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.