Implement the Mean Squared Error (MSE) loss function.
Given a vector of true values y and predicted values y^:
MSE=n1∑i=1n(yi−y^i)2
MSE is one of the most common loss functions for regression tasks. Squaring the errors penalises large deviations more heavily than small ones.
y_true = [1, 2, 3] y_pred = [1, 2, 3] Output: 0.0 # perfect predictions y_true = [0, 0, 0] y_pred = [1, 1, 1] Output: 1.0
float.