Starting from:

$25

ME8813-Homework 1 Solved

source  file(s),  where  the       main    executable       file       should  be        named  as  ME8813ML_Homework1_YourLastName_FirstName.py.

 

A simple python file regr_data.py is given, where a small dataset 𝑥 , 𝑦 is generated for regression. Implement the quasi-Newton optimization method, Davidon-Fletcher-Powell Method, to perform the data fitting process. The model to be fitted is:

                                                      𝑌 𝑝 𝑝 cos 2𝜋𝑥              𝑝 cos 4𝜋𝑥         𝑝 cos 6𝜋𝑥

 
Your implementation of the optimization method should be included in a function p=DFP_fit(x,y,epsilon) where x and y are the vectors of training data corresponding to the input and output of the model, and epsilon is the error threshold users can specify for the stopping criteria. You can choose to implement any of the stopping criteria discussed in the lecture. The function should return the fitted parameters p = [p0, p1, p2, p3].  

 
Plot the predictions from your fitted model right below the original data as the comparison.  
 

As the hint, the loss function or objective function to be minimized is:  

_

         𝐿 𝑝 , 𝑝 , 𝑝 , 𝑝                                              𝑝 𝑝 cos 2𝜋𝑥 𝑝 cos 4𝜋𝑥 𝑝 cos 6𝜋𝑥 𝑦

The search space for the optimization is 4-dimensional as (p0, p1, p2, p3). The gradient function ∇L as the first derivative respect to p’s can be derived analytically and hard coded.  

More products