Question: Create a randon one dimensional dataset x = np . arange ( 0 , 1 0 0 ) y = x + np . random.rand

Create a randon one dimensional dataset
x = np.arange(0,100)
y = x + np.random.rand(100)*30
plt.scatter(x,y)
Problem 1
a) Fit a regression line on the dataset created above using sklearn.linear_model LinearRegression, use default hyperparameters
b) Print out the regression intercept and coefficients
c) Plot the data in blue and the regression line in red
d) Predict the y value for x=45 and show it on the plot in green.
Problem 2
a) Fit a regression line on the dataset created above using tensorflow and keras, use default hyperparameters, sequential model, one dense neuron, activation='linear'. Use 'rmsprop' optimizer and mean squared error for the loss function. Use 1000 epochs.
b) Print out the regression intercept and coefficients
c) Plot the data in blue and the regression line in red
d) Predict the y value for x=45 and show it on the plot in green
e) Print the coefficients in the keras model and compare to the scikit learn modelen

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!