# Regression, classification, and ranking with loss functions in neural networks

Why are some loss functions better at optimizing one type of problem than another? In other words, what are some factors to consider when choosing one cost function over another?

In regression problems, usually $L=\sum_i(y_i-\hat y_i)^2$ (mean square error) is the loss function used, even when the metric is the mean absolute error: $L=\sum_i|y_i-\hat y_i|$, for the reason I explained before.
In classification problems, you would minimize either a cross-entropy function to maximize for example accuracy (which is just $\sum_i y_i=\hat y_i$, i.e. the number of times your prediction is correct).