1-1 The Euclidean distance between \(x^*\) and \(x_n\) is defined as \(d(x^*, x_n) =\sqrt{\sum^P_{p=1}|x^*_p-x_{np}|^2}\). Given a new covariate \(x^* = (3, 4)\), please calculate the distance between \(x^*\) and each \(x_n\).

\(x_1\)\(d(x^*,x_1) = \sqrt{(3-2)^2+(4-1)^2}=\sqrt{10}\)

\(x_2\)\(d(x^*,x_2) = \sqrt{(3-3)^2+(4-4)^2}=0\)

\(x_3\)\(d(x^*,x_3) = \sqrt{(3-1)^2+(4-2)^2}=\sqrt{8}=2\sqrt{2}\)

\(x_4\)\(d(x^*,x_4) = \sqrt{(3-5)^2+(4-4)^2}=2\)

\(x_5\)\(d(x^*,x_1) = \sqrt{(3-1)^2+(4-2)^2}=2\sqrt{2}\)

\(x_6\)\(d(x^*,x_6) = \sqrt{(3-4)^2+(4-5)^2}=\sqrt{2}\)


1-2 For K = 1, 2, 3, what is \(N_K(x^*)\) (the index set of K-nearest neighbors of \(x^* = (3, 4)\))?

K = 1, \(N_1(x^*) = \{2\}\)

K = 2, \(N_2(x^*) = \{2,6\}\)

K = 3, \(N_3(x^*) = \{2,6,4\}\)


1-3 For K = 1, 2, 3, find the \(\hat{f}(x^*)\) at \(x^* = (3, 4)\) under the unweighted K-nearest neighbors regression.

K = 1, \(\hat{f}(x^*) = f(x_2) = 6\)

K = 2, \(\hat{f}(x^*) = \frac{f(x_2)+f(x_6)}{2} = (6+5)/2=5.5\)

K = 3, \(\hat{f}(x^*) = \frac{f(x_2)+f(x_6)+f(x_4)}{3} = (6+5+4)/3=5\)