There are many forms that a loss function can take. Deep learning introduces a much more general approach to constructing loss functions but this intro to loss functions should get you thinking about it the right way.
A loss function is something that ML algorithms seek to minimize.
Every model comes with its own loss function that it minimizes either implicitly or explicitly Orderinary least squares (OLS) minimizes the sum of squared residuals. Lasso, ridge, and elastic net minimize an additional penalty term to OLS. Regression trees greedily solve where indicates predictor spaces (pg. 306 from this book for me info), and neural networks minimize whatever loss function is given them.
Though models minimize loss functions, what are some general types of loss functions and what are each of them good for?
Let .
Let's simplify thinking about this function by just considering a single value of and plotting the loss as a function of a single loss amount .
MSE becomes . Which is a parabola.
Absolute deviation becomes which is a V shape with the bottom of the V on the origin.
Asymetric loss becomes
Which is V shaped loss function with the V on the origin, the difference this time is that over estimates (positive values of ) have slope while underestimates increase in loss at a rate of . Note that absolute loss is a special case of asymmetric loss with
What are some differences between squared loss and absolute loss? First note that when absolute loss is greater than squared loss. But note that when MSE is greater and grows exponentially larger than absolute deviation. Knowing this, which model would be more resistant to high noise data when sample size is small? What would be real world example of when MSE would be more appropriate than mean absolute deviation?
Now consider asymmetric loss. When is close to over predictions receive large loss with almost no loss for under estimates. On the other hand when is close to the relationship is reversed.
The loss functions discussed so far only make sense in a regression context. What would the general form for the loss of a binary classifier look like? If and then what values could we have for with ? . would correspond to false positives, would be a false negative, and would be if the classification were correct. Therefore our loss function would look like this:
It can be shown that the best loss prediction given a squared loss function is .
The best prediction for absolute loss is .
For asymmetric loss, the best prediction is . Again, this is the median when .
For classification loss, the best prediction is