Mean Square Error
The MSE loss function is used for linear regression models.
Derivation
Calculate the square difference between:
- Prediction
formed by the model for some given inputs - True value
We then repeat this operation for every sample
We thus solve for the optimisation problem:
The derivates with respect to
These are the update rules:
With
def loss_mse(a, b, x, y):
val = np.sum((y - (a*x + b))**2 / x.shape[0]
return '{:.2e}'.format(val)