Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Numpy, matplot, and sklearn only. 1. Generate 500 random X values from -3 to 3. 2. Generate 500 Y values using distribution y=0.5*X 5

Use Numpy, matplot, and sklearn only.

1. Generate 500 random X values from -3 to 3.

2. Generate 500 Y values using distribution "y=0.5*X5 - X3 - X2 +2+a little bit randomness (both positive and negative) "

e.g.

m = 500 np.random.seed(seed=5) X = 6 * np.random.random(m).reshape(-1, 1) - 3 y = 0.5 * X**5 -X**3- X**2 + 2 + 5*np.random.randn(m, 1)

# y with both positive and negative randomness added

3. Use X and Y as the whole dataset and use 200 samples as testing + 300 samples as training.

Testing and training sets must be disjoint.

4. Try Linear Regression and Polynomial Regression (PolynomialFeatures + LinearRegression) in SKLearn from degree 2 to 25 to fit the training data samples.

5. Calculate the loss using mean squared error loss = average ( sum (prediction - y)2 ) for all the training samples after the model was selected.

6. Calculate the loss using mean squared error loss = average ( sum (prediction - y)2 ) for all the testing samples after the model was selected and used for testing data predictions.

7. Plot the figures showing your predictions using degree =2, 5, 8, 10, 20.

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

=+ what roles should government play in them ?

Answered: 1 week ago

Question

=+ Why do we have markets and, according to economists,

Answered: 1 week ago