Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In practice, PXY is usually unknown and we use the empirical risk minimizer (ERM). We will reformulate the problem as a d-dimensional linear regression problem.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

In practice, PXY is usually unknown and we use the empirical risk minimizer (ERM). We will reformulate the problem as a d-dimensional linear regression problem. First note that functions in Hd are parametrized by a vector b=[b0,b1,bd], we will use the notation fb. Similarly we will note aR3 the vector parametrizing g(x)=fa(x). We will also gather data points from the training sample in the following matrix and vector: X=111x1x2xNx1dx2dxN,y=[y0,y1,yN] These notations allow us to take advantage of the very effective linear algebra formalism. X is called the design matrix. Open the source code file hw1_code_source.py from the .zip folder. Using the function get_a get a value for a, and draw a sample x_train, y_train of size N=10 and a sample x_test, __test of size Ntest=1000 using the function draw_sample. 7. (2 Points) Write a function called least_square_estimator taking as input a design matrix XRN(d+1) and the corresponding vector yRN returning b^R(d+1). Your function should handle any value of N and d, and in particular return an error if Nd. (Drawing x at random from the uniform distribution makes it almost certain that any design matrix X with d1 we generate is full rank). 8. (1 Points) Recall the definition of the empical risk R^(f^) on a sample {xi,yi}i=1N for a prediction function f^. Write a function empirical_risk to compute the empirical risk of fb taking as input a design matrix XRN(d+1), a vector yRN and the vector bR(d+1) parametrizing the predictor. 9. (3 Points) Use your code to estimate b^ from x_train, y_train using d=5. Compare b^ and a. Make a single plot (Plot 1) of the plan (x,y) displaying the points in the training set, values of the true underlying function g(x) in [0,1] and values of the estimated function fb^(x) in [0,1]. Make sure to include a legend to your plot . 10. (1 Points) Now you can adjust d. What is the minimum value for which we get a "perfect fit"? How does this result relates with your conclusions on the approximation error above

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

More Books

Students also viewed these Databases questions

Question

Relational Contexts in Organizations

Answered: 1 week ago