# Continuous loss function that can measure one-side error

I am predicting a target $$y$$ using regression. In my application, the prediction $$\hat{y}$$ should be always no less than $$y$$. If $$y>\hat{y}$$, it is definitely a wrong prediction. On the $$y<\hat{y}$$ side, I want $$\hat{y}$$ is close to $$y$$.

In this case, I cannot use $$(\hat{y}-y)^2$$ to measure the error because it measures two sides. I guess it should be a common case in ML practices. Is there any commonly used continuous loss function that measures on-side error?

How about something like: $$\begin{eqnarray} (y-\hat{y})^2 , y < \hat{y} \\ (y-\hat{y})^3 , y \geq \hat{y} \end{eqnarray}$$
This is both continuous and differentiable, and penalizes $$y > \hat{y}$$ more severely than $$y < \hat{y}$$. You can even control the severity of the penalization by changing the exponent from 3 to a higher odd number.
Here's how it looks ($$x = y - \hat{y}$$):