Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make the appropriate design matrix for multivariate linear regression for this question by inserting a column of ones to the begining of x data (

Make the appropriate "design matrix" for multivariate linear regression for this question by inserting a column of ones to the begining of x data
(we do this to add an intercept to the regression line).
Hint: use np. concatenate((a, b), axis=1)
where a is an array of ones of the same length as the number of features, and b is the input data. Axis 1 means that we want to add a column
rather than a row.
[] ### Write your code below
vv Part b:
Split the data into training and testing sets. You may use the included scikitlearn train and test function for this step. Please split using an 80%
train/20% test split. Here is an example of how to use the function:
x_train, x_teat, y_train, y_test = train_test_split , test_size =0.2)
Use the train data to solve for the estimated regression weights using the
hat()=(xTTx)-1xTTY
formula. Be mindful of matrix dimensions!
Use a loop to repeat this whole process five times (i.e. split into train/test five times and calculate the weights for each split) and print all
estimated weghts.
[] np. random. seed (seed)
### Write your code below (don't forget to label any graphs). I put pass in the loop as a placeholder, please remove it when you write your code
kfolds =5
for i in range(kfolds):
pass
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

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

Students also viewed these Databases questions

Question

3 The distinction between microeconomics and macroeconomics.

Answered: 1 week ago