Let k be the number of nearest neighbors and D be the set of training examples
- for each test example z = (x’,y’) do
- Compute d(x’,x), the distance between z and every example, (x,y) ϵ D
- Select Dz ⊆ D, the set of k closest training examples to z


Let k be the number of nearest neighbors and D be the set of training examples