Ex. 18.14
Ex. 18.14
Distance weighted 1-NN classification. Consider the 1-nearest-neighbor method (Section 13.3) in a two-class classification problem. Let \(d_+(x_0)\) be the shortest distance to a training observation in class +1, and likewise \(d_-(x_0)\) the shortest distance for class -1. Let \(N_-\) be the number of samples in class -1, \(N_+\) the number in class \(+1\), and \(N=N_- + N_+\).
(a) Show that
can be viewed as a nonparametric discriminant function corresponding to \(1\)-NN classification. [Hint: Show that \(\hat f_+(x_0)=\frac{1}{N_+d_+(x_0)}\) can be viewed as a nonparametric estimate of the density in class +1 at \(x_0\)].
(b) How would you modify this function to introduce class prior probabilities \(\pi_+\) and \(\pi_-\) different from the sample-priors \(N_+/N\) and \(N_-/N\)?
(c) How would you generalize this approach for \(K\)-NN classification?
Soln. 18.14
(a) Note that \(\delta(x_0) > 0\) is equivalent to \(d_-(x_0) > d_+(x_0)\), thus we can assign \(x_0\) to class \(+1\). Therefore \(\delta (x_0)\) can be viewed as a nonparametric discriminant function corresponding to \(1\)-NN classification.
(b) Note that by Bayes formula, we have
Therefore we have
(c) For \(k\)-NN, given \(x_0\), compute the distances \(d(x_0, x_k)\) between \(x_0\) and \(K\) closest training samples \(x_k\) for \(k=1,...,K\). Then we can choose nonparametric discriminant function as
where \(w_k\) represents the weights and in our case \(w_k = \frac{1}{d(x_0, x_k)}\) for \(k=1,...,K\).