The expected absolute error is minimized when the prediction is the median of the observations.
October 4, 2021 · 3 min read
We observe y=f(x)+ϵ. As usual, y is what we observe, f(x) is the true data generating process, and ϵ is random noise uncorrelated with the data generating process. Note that y is really a function of x. In other words, y=y(x)
Our model, f^(x) generates predictions y^.
We choose to minimize the absolute deviation of our model’s predictions with the outcomes. Put mathematically,
Note that we are evaluating at a specific value of x. Many data scientists will omit this detail but it’s necessary for a correct understanding of what the model is optimizing. We don’t want a model that gives the median value of y, we want one that gives the median value of y at a particular value of x.
For sake of not being over encumbered, we Write E[∣y−y^∣x]=E[∣y−y^∣]. In other words, it’s implied that we’re considering a single slice at x.
Finally, remember that our model is deterministic and is not subject to noise. Therefore, we’re finding the best y^ over all possible values of y. Let y by a continuous random variable, then:
E[∣y−y^∣]=∫−∞∞loss∣y−y^∣probability of lossp(y)dy
Our goal is to find the optimal y^ over this, this can be done by solving first order conditions but we don’t know how to take the derivative of a function with an absolute value. Let’s get rid of the absolute value.