Question: Part 1: Defining cost functions We need to define cost functions before creating a linear regression model to calculate the error between our prediction and
Part 1: Defining cost functions
We need to define cost functions before creating a linear regression model to calculate the error between our prediction and the true values. We will define two cost functions: Mean Squared Error (MSE) and Mean Absolute Error (MAE).
Task 1.1: Mean Squared Error (MSE)
Write the function mean_squared_error(y_true, y_pred) that returns a number representing the mean squared error of the predictions.
The formula for Mean Squared Error is as follows:

Hint: Consider using np.square or np.power.
The formula for Mean Squared Error is as follows: MSE(y,y^)=2m1i=1m(y^iyi)2 where y is the vector with actual values, y^ is the prediction vector, and m is the number of samples in the training data
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
