m 150 pts| Locally Weighted Linear Regression In this part of the assignment you are going to implement locally weighted

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

m 150 pts| Locally Weighted Linear Regression In this part of the assignment you are going to implement locally weighted

Post by answerhappygod »

M 150 Pts Locally Weighted Linear Regression In This Part Of The Assignment You Are Going To Implement Locally Weighted 1
M 150 Pts Locally Weighted Linear Regression In This Part Of The Assignment You Are Going To Implement Locally Weighted 1 (58.15 KiB) Viewed 41 times
You have to use python
m 150 pts| Locally Weighted Linear Regression In this part of the assignment you are going to implement locally weighted linear regression. The difference of locally weighted linear regression from normal linear regression is that in the latter case all the weights (the ws) were considered to be the same (i.e. all l's). You will minimize the following function. MSE(O) = ""(87z0 – ym)? Generate synthetic data using a function y = sin(2x) + €, where m=100 (number of training examples) and ε is a random noise. Example in python: m=100; X-np.random.rand(m. 1)*2 y = np.sin(math.pi*X)+np.random.randn(m) m i=1 1. (30 pts] Update the linear regression function that you implemented in (2) so that local weights are also considered in taking the gradient of a cost function. The function should have the following header: theta= weighted linear regression(X, Y, iteration cnt, eta, x, tau) where x is a query point, tau is bandwidth parameter. Use eta 0.4 and iterNo=100 When evaluating h() at a query point x, use weights w") = exp(- 2r? a With a bandwidth parameter 1 = 0.1. (Again, remember to include intercept term). Plot on the same figure the data and the curve resulting from your fit. Note: The query samples are the samples coming from training set itself. Since you have 100 samples in your training set you will call weighted_linear regression 100 times, each time selecting one of the samples from your training set. II. 120 pts) Repeat (1) five times with r = 0.001,0.01,0.3.1 and 10. Comment briefly on what happens to the fit when t is too small or too large. Given the fixed parameters for learning rate and number of iterations as above, what is the best tau to fit your synthetic data?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply