Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1e)For the polynomial degree that produces the lowest mean square error from the above cross validation, conduct fit_transform for X_train and X_test data into X_train1

1e)For the polynomial degree that produces the lowest mean square error from the above cross

validation, conduct fit_transform for X_train and X_test data into X_train1 and X_test1.

Fit X_train1 and y_train by linear regression.

Print mean sqaure error of the linear regression for y_test and predicted X_test1 data.

image text in transcribed
I scatter plot python of csv list - Bi X _ Importing a .CSV file into Python X Final Exam 2021-4-28 - Jupyter | X + X C @ localhost:8889otebooks/Final%20Exam%202021-4-28.ipynb Sign in jupyter Final Exam 2021-4-28 Last Checkpoint: Last Wednesday at 9:30 PM (unsaved changes) Logout File Edit View Insert Cell Kernel Widgets Help Trusted |Python 3 0 + Run C H Code In [55]: for i in range(1, 5): poly = PolynomialFeatures (degree=i) X_current = poly . fit_transform(X) model = 1m. fit(X_current, y) scores = cross_val_score(model, X_current, y, scoring="neg_mean_squared_error", cv=crossvalidation, n_jobs=1) print( "Degree-"+str(i)+" polynomial MSE: " + str(np. mean(np. abs(scores) ) ) + ", STD: " + str(np. std(scores)) ) Degree-1 polynomial MSE: 6175 . 86230435149, STD: 733. 3016322580443 Degree-2 polynomial MSE: 6231. 278307870103, STD: 760. 8446044009296 Degree-3 polynomial MSE: 5746. 4567285767935, STD: 820.5190135301506 Degree-4 polynomial MSE: 5813 . 510141003943, STD: 897. 3891535623625 In [ ]: # le) For the polynomial degree that produces the Lowest mean square error from the above cross # validation, conduct fit_transform for X_train and X_test data into X_train1 and X_test1. # Fit X_trainl and y_train by Linear regression. # Print mean sqaure error of the Linear regression for y_test and predicted X_test1 data. In [ ] : In [ ]: # 1f) Comparing the mean square errors between #1d and #le, we see different MSE results. # Try to explain why they can be different. Answer: In [ ] : Type here to search O DELL O X 0 0 7 12:22 AM 5/1/2021

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

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions