Solved – How to design and implement an asymmetric loss function for regression

errorloss-functionsregression

Problem

In regression one usually computes the mean squared error (MSE) for a sample:
$$
\text{MSE} = \frac{1}{n} \sum_{i=1}^n\left(g(x_i) – \widehat{g}(x_i)\right)^2
$$
to measure the quality of a predictor.

Right now I'm working on a regression problem where the goal is to predict the price customers are willing to pay for a product given a number of numeric features. If the predicted price is too high no customer will buy the product, but the monetary loss is low because the price can simply be decremented. Of course it should not be too high as then the product may not be bought for a long time. On the other hand if the predicted price is too low, the product will be bought quickly without the chance to adjust the price.

In other words the learning algorithm should predict slightly higher prices which can be decremented if necessary rather than underestimating the true price which will result in an immediate monetary loss.

Question

How would you design an error metric incorporating this cost asymmetry?


Possible Solution

A way to define an asymmetric loss function would be to simply multiply by a weight:
$$
\frac{1}{n} \sum_{i=1}^n \left| \alpha – \mathbb{1}_{(g(x_i) – \widehat{g}(x_i)) < 0} \right|\cdot \left(g(x_i) – \widehat{g}(x_i)\right)^2
$$
with $\alpha \in (0,1)$ being the parameter we can adjust to change the degree of asymmetry. I've found it here. This seems like the most straight forward thing to do, while maintaining the quadratic loss.

Best Answer

As mentioned in the comments above, quantile regression uses an asymmetric loss function ( linear but with different slopes for positive and negative errors). The quadratic (squared loss) analog of quantile regression is expectile regression.

You can google quantile regression for the references. For expectile regression see the R package expectreg and the references in the reference manual.