Question: Write a function linearModelFit to fit a linear model. The function should take as its first argument the design matrix x as a 2 d

Write a function linearModelFit to fit a linear model. The function should take as its first argument the design matrix x as a 2d-array,
as its second argument a 1d-array y of outcomes, and as its third argument a function loss fcn which returns as a tuple the value of the
loss, as well as the gradient of the loss. As a result, it should return the estimated betas and the R2.
Test the function with these values:
x=np.array([10-12]
1
1
1)
y=np.array([0,0.4,2])
It must return:
Betas: [0.60.6]
R2: 0.75
 Write a function linearModelFit to fit a linear model. The function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!