# Heavy regression loss for false non 0 prediction

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

• 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. – seanv507 Aug 24 '19 at 15:49
• 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? – Alexander Vocaet Aug 26 '19 at 7:25
• 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 – seanv507 Aug 26 '19 at 9:22