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.


