Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions