Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fill in the test_polynomials function. This function should take in a list of positive integer values, corresponding to different degrees for polynomial models (so if

Fill in the test_polynomials function. This function should take in a list of positive integer values, corresponding to different degrees for polynomial models (so if the degree is 1, we get a purely linear model, if it is 2, we first transform the data so it is degree-2, and so on). Each model should be fit to the entire data-set, and then the model should be used to predict outputs for that data-set. The function will return two lists. One will consist of the predictions, i.e., it will be a list of length P, where P is the number of different polynomial degrees, and each element of the list consists of the N output values, where N is the size of the overall data-set). The other will consist of the P error values for the models, where the error is calculated using the mean squared error metric (MSE). Once the function is completed, it should be called using the sequence of degrees d {1, 2, 3, 4, 5, 6, 10, 11, 12}. Once the function returns its two lists, the plot_predictions function (already written for you) will produce a plot containing each of the models predictions, along with their MSE values (found in the title area of each subplot).

image text in transcribed

def test_polynomials(polynomials-list(): "Generates a series of polynomial regression models on input data. Each model is fit to the data, then used to predict values of that input data. Predictions and mean squared error are collected and returned as two lists. Args polynomials : list of positive integer values Each value is the degree of a polynomial regression model, to be built. Returns prediction_list: list of arrays ((# polynomial models) x (# input data)) Each array contains the predicted y-values for input data. error_list: list of error values ((# polynomial models) x 1) Each value is the mean squared error (MSE) of the model with the associated polynomial degree. prediction_list list) error_list = list() # TODO: fill in this function to generate the required set of models, # returning the predictions and the errors for each. return prediction_list, error_list # TODO: generate the sequence of degrees, call test_polynomials to create models, use plot_predictions to show the results # def test_polynomials(polynomials-list(): "Generates a series of polynomial regression models on input data. Each model is fit to the data, then used to predict values of that input data. Predictions and mean squared error are collected and returned as two lists. Args polynomials : list of positive integer values Each value is the degree of a polynomial regression model, to be built. Returns prediction_list: list of arrays ((# polynomial models) x (# input data)) Each array contains the predicted y-values for input data. error_list: list of error values ((# polynomial models) x 1) Each value is the mean squared error (MSE) of the model with the associated polynomial degree. prediction_list list) error_list = list() # TODO: fill in this function to generate the required set of models, # returning the predictions and the errors for each. return prediction_list, error_list # TODO: generate the sequence of degrees, call test_polynomials to create models, use plot_predictions to show the results #

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

7. Where Do We Begin?

Answered: 1 week ago