3
$\begingroup$

My regression should predict values >=0 But a wrongly predicted value >0(e.g. 0.001 instead of 0) is much worse then a a slight missprediction of 0.001 (e.g. 0.002 instead of 0.003)

I am thinking about a costume loss function that weights the false non zeros to return a big loss.

Is there a more elegant way ?

Edit:

this is my unelegant sollution:

def custom_loss(y,yh):
    if y == 0:
        loss = tf.math.minimum(100,yt*100000)
    else :
        loss = losses.mean_squared_error(yh,y)

    return loss
$\endgroup$
3
  • 1
    $\begingroup$ I think you have to be very clear on why you want to do this. A regression gives you a conditional expectation, IE an average value, whereas you seem almost to perform a classification. So I am sure there is a more elegant way once you explain what the overall goal is. $\endgroup$
    – seanv507
    Aug 24, 2019 at 15:49
  • $\begingroup$ it almost seems like a classification. I want to predict the amount of land usage by an agent. but the model sometimes predicticts tiny land usages which are totally unreasonable. Is another approach to encompass model standard deviation and set every prediction zero within 0+stdDev? $\endgroup$ Aug 26, 2019 at 7:25
  • 1
    $\begingroup$ I would say thresholding would be a natural approach, yes... but it depends what the prediction is for. you migth also look at hurdle models.stata.com/stata14/hurdle-models $\endgroup$
    – seanv507
    Aug 26, 2019 at 9:22

1 Answer 1

1
$\begingroup$

One option would be Huber Loss which could be setup to increase the weight for some types of errors compared to other errors.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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