Answered step by step
Verified Expert Solution
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 data
we do this to add an intercept to the regression line
Hint: use np concatenatea b axis
where is an array of ones of the same length as the number of features, and is the input data. Axis means that we want to add a column
rather than a row.
### Write your code below
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
train test split. Here is an example of how to use the function:
xtrain, xteat, ytrain, ytest traintestsplit testsize
Use the train data to solve for the estimated regression weights using the
hat
formula. Be mindful of matrix dimensions!
Use a loop to repeat this whole process five times ie split into traintest five times and calculate the weights for each split and print all
estimated weghts.
np random. seed seed
### Write your code below dont forget to label any graphs I put pass in the loop as a placeholder, please remove it when you write your code
kfolds
for in rangekfolds:
pass
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started