Part2. Goal/Objective: Apply linear regression on a synthetic data of the form y = 0.75x + 2x2 + 1. 1. A) Similar to part one, generate 200 data samples but this time adjust values of x to be in the range of -3 to 3. Plot the data and split into training and testing PART 1 QUESTION FOR REFERENCE IN ATTACHED PHOTO B)Use Linear Regression on the generated data and plot the results. Discuss your findings. C)Combine polynomial features of the generated data using scikit-learn’s Polynomial Features and fit combined features to a linear regression using the training dataset. Generate 100 samples between -3 to 3 with uniform interval that will be used to generate predictions from the fitted model (note: numpy.linespace can be used to generate evenly spaced

Advanced Engineering Mathematics
10th Edition
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Erwin Kreyszig
Chapter2: Second-order Linear Odes
Section: Chapter Questions
Problem 1RQ
icon
Related questions
Question

Part2. Goal/Objective: Apply linear regression on a synthetic data of the form y = 0.75x + 2x2 + 1.

1. A) Similar to part one, generate 200 data samples but this time adjust values of to be in the range of -3 to 3. Plot the data and split into training and testing

PART 1 QUESTION FOR REFERENCE IN ATTACHED PHOTO

B)Use Linear Regression on the generated data and plot the results. Discuss your findings.

C)Combine polynomial features of the generated data using scikit-learn’s Polynomial Features and fit combined features to a linear regression using the training dataset. Generate 100 samples between -3 to 3 with uniform interval that will be used to generate predictions from the fitted model (note: numpy.linespace can be used to generate evenly spaced numbers). Compare the model’s prediction with the ground truth by plotting the prediction as a line and the ground truth as data points on the same graph.

 

Note:

  • PolynomialFeatures Reference:
  • Be sure to not include_bias when combining polynomial features
Goal/Objective: Apply linear regression on a synthetic data of the form y = 12x - 4.
1) Using numpy sample 200 numbers from a uniform distribution and store it into variable
x. Generate y data using x and injecting noise from the gaussian distribution (i.e. y = 12x-
4 + noise). Using matplotlib plot the data samples, configuring axis so all samples are
clearly visible. Split the data into training (80%) and testing (20%) sets using scikit-learn
Note:
Ensure to set the random seed to reproduce same random number during different
execution times.
import numpy as np
import numpy. random as rnd
np. random.seed (10)
Transcribed Image Text:Goal/Objective: Apply linear regression on a synthetic data of the form y = 12x - 4. 1) Using numpy sample 200 numbers from a uniform distribution and store it into variable x. Generate y data using x and injecting noise from the gaussian distribution (i.e. y = 12x- 4 + noise). Using matplotlib plot the data samples, configuring axis so all samples are clearly visible. Split the data into training (80%) and testing (20%) sets using scikit-learn Note: Ensure to set the random seed to reproduce same random number during different execution times. import numpy as np import numpy. random as rnd np. random.seed (10)
import numpy as np
from
>>> X = np.arange (6).reshape (3, 2)
>>> X
sklearn.preprocessing
array([[0, 1],
[2, 3],
[4, 5]])
>>> poly
>>>poly.fit transform (X)
1.],
6.1
9.],
4.1
3.1
2.1
5., 16., 20., 25.]])
[ 1or 4.,
>>> poly = Polynomial Features interaction_only=True)
>>>poly.fit transform (X)
0.F
=
Polynomial Features (2)
array([[ 1.,
[ 1.,
array([[ 1.,
[ 1.p
[ 1.,
0.f
4.,
1.,
1.s
3.1
5.1
0.f
import Polynomial Features
0.],
0.f
6.].
20.]])
Transcribed Image Text:import numpy as np from >>> X = np.arange (6).reshape (3, 2) >>> X sklearn.preprocessing array([[0, 1], [2, 3], [4, 5]]) >>> poly >>>poly.fit transform (X) 1.], 6.1 9.], 4.1 3.1 2.1 5., 16., 20., 25.]]) [ 1or 4., >>> poly = Polynomial Features interaction_only=True) >>>poly.fit transform (X) 0.F = Polynomial Features (2) array([[ 1., [ 1., array([[ 1., [ 1.p [ 1., 0.f 4., 1., 1.s 3.1 5.1 0.f import Polynomial Features 0.], 0.f 6.]. 20.]])
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Advanced Engineering Mathematics
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Basic Technical Mathematics
Basic Technical Mathematics
Advanced Math
ISBN:
9780134437705
Author:
Washington
Publisher:
PEARSON
Topology
Topology
Advanced Math
ISBN:
9780134689517
Author:
Munkres, James R.
Publisher:
Pearson,