Loss = "How Wrong Are We?"
Every learning algorithm needs a number that says how badly the model is doing. That number is called loss, and the choice of loss function is one of the most important decisions in ML — it shapes what the model considers "wrong."
Three Workhorses
| Loss | Formula | Use when |
|---|---|---|
| Mean Squared Error (MSE) | Regression. Penalizes big errors heavily. | |
| Mean Absolute Error (MAE) | Regression with outliers. Treats all errors linearly. | |
| Cross-Entropy | Classification. Probabilistically grounded. |
MSE vs MAE — Why the Squaring Matters
MSE squares the error, so a residual of 10 contributes 100 while a residual of 1 contributes only 1. The model learns to desperately avoid big errors, even at the cost of being slightly worse on small ones. Good when small errors are forgivable but big ones are catastrophic. Bad when you have outliers (the squaring makes outliers dominate the loss).
MAE treats every error linearly. A residual of 10 contributes 10. The model is more tolerant of outliers but cares less about small refinements.