Answered step by step
Verified Expert Solution
Question
1 Approved Answer
la funcion definida en el ejercicio 4 y 5 deben ser usadas en este problema las puedes definir con el nombre que quieras y yo
la funcion definida en el ejercicio 4 y 5 deben ser usadas en este problema las puedes definir con el nombre que quieras y yo las sustituyo
6. (2 points) Create a function called best model that takes as argument a list called x that contains numbers, a list called y that also contains numbers, and a list called all models that contains lists. Each list in all models contains two numbers that represent a [m,b] combination. Each [m,b] combination represents a set of parameters that define a different linear model. For example, if all models-[[4.4,5]. [1.5,3]], then each list represents a set of parameters that define the linear models: 462 123 Model 1:9 Model 2: 9, 4.4 xx, +5 1.5 xx, +3 The function best medel must compute the predictions (9) and the SSE of each model based on the model parameters and the values in the x and y lists. Finally, the function must return the model parameters that result in the minimum SSE (i.c., the best model). Note that you can use the functions defined in Problems 4 and 5 within best_model. 124 125 126 #--- 127 # Solution to Exercise # 6 #START CODE HERE 128 129 130 #END CODE HERE 131 132 133 134 135 136 137 138 ### TEST CASE FOR EX 6 ### Run the following lines. # If you get "Correct" you # did it right. x = [1,3,5] y = [2.5, 6.5, 10.5] all models [[3,-1], [2,0.25], [2.5, 0.1]] result[] use your function here; delete the empty list if result = [2, 0.25]: 139 140 141 142 143 14 print("Correct!") 145 else: 146 print("Incorrect :(") 147 148 149 150
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started