Question: write the python code and carry out the following requirements a) Generate a synthetic 2-D data set with 100 data points where 0 x 1,0


write the python code and carry out the following requirements 
a) Generate a synthetic 2-D data set with 100 data points where 0  x  1,0  x  1 are evenly spaced. Assign the

a) Generate a synthetic 2-D data set with 100 data points where 0 x 1,0 x 1 are evenly spaced. Assign the data with target values y = sin(x + 5x2) polluted by random noise. Use LinearRegression model in sk-learn to train the dataset. Use Polynomial Features to map the generated dataset into higher dimension space and train the dataset with LinearRegression model. Plot the mean square errors with regard to the polynomial degree ranging from 1 to 10. b) When the degree of polynomial feature mapping is 3, the new input data will be 10-D, so linear model will train 10 weights. Try to use Ridge regression model with the following parameters and find the new weights: (i) = 0.1, (ii) = 0.01, (iii) = 0.001. Create a plot showing how these weights change with values. Explain what effects does have on the trained model? c) Now try to use Lasso regression model with the following parameters and find the new weights: (i) = 0.1, (ii) = 0.01, (iii) = 0.001. Explain what effects does have on the trained model? Talk about similarities and differences between Ridge and Lasso

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a To generate the synthetic 2D dataset map it into a higherdimensional space using PolynomialFeatures and train it with a LinearRegression model you c... View full answer

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 Programming Questions!