Question
Consider a single dimension (variable) X. Obtain N = 100 iid samples x1, x2, of X uniformly randomly between 1 and 10, and then obtain
Consider a single dimension (variable) X. Obtain N = 100 iid samples x1, x2, of X uniformly randomly between 1 and 10, and then obtain the corresponding y values as the natural logarithm of x plus a Gaussian noise (mean 0, standard deviation 0.1), with different points having different amounts of noise. Now use K-NN regression to obtain y values (= estimates of y) at x-values of 1, 3, 5, 7 and 9 for each of the following three schemes: the K neighbors contribute equally (separately for K = 1, 3, 50) each of the K neighbors has an influence that is inversely proportional to the distance from the point (separately for K = 1, 3, 50) all the N points contribute, with each contribution proportional to e 1 2 d 2 , where d represents distance. Print the numerical values of the (x, y) pairs for each of the above cases (there should be a total of 3 + 3 +1 = 7 cases and 5 (x, y) pairs for each case). Also, plot the (x 0 , y0 ) and (x, y) points for each of these seven cases, where x 0 is the point (out of the 100 sample points) closest to x and y 0 is the y-value of x 0 (there should be a total of 7 plots for this, each plot showing the (x 0 , y0 ) and (x, y) points). It is possible but unlikely that x and x 0 coincide.Use Python
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