Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 : Models for Data ( 2 5 points ) y x A model is a function that takes an input and produces a

Exercise 2: Models for Data (25 points)
y
x
A model is a function that takes an input and produces a prediction *
Let's consider two possible models for this data:
M1(x)=x+5
M2(x)=2x+1
Compute the predictions of models M1 and M2 for the values in x. These predictions should be vectors Y
of the same shape as . Then plot the prediction lines of these two models overlayed on the "observed" data (x,Y). Use plt.plot() to draw the lines. Note: you will generate only one plot. Make sure to include axes, titles and legend.
Evaluation Metrics
How good are our models? Intuitively, the better the model, the more closely it fits the data we have. y
x
That is, for each , we'll compare y, the true value, with *, the predicted value. This comparison is often y
called the loss or the error. One common such comparison is squared error: (y-????)2. Averaging over all our data points, we get the mean squared error.
1
yi
MSE =-lonY(yi-hat(i)i)2
Exercise 3: Computing MSE (25 points)
Write a function for computing the MSE metric and use it to compute the MSE for the two models above, M1 and M2.
def MSE(true_values, predicted_values):
""'"Return the MSE between true_values and predicted values.""."
# YOUR CODE HERE
print ('MSE for M1:', MSE(Y, M1))
print ('MSE for M2:', MSE(Y, M2))
MSE fo
r M1:
None
MSE fo
r M2:
None
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions