Let’s say we have a sample set and is the sample while .

We want to measure the distance (let’s say, using Euclidean distance):

And so, the nearest neighbor decision is

Note here that is the ground truth class of , while is the predicted class of .

Nearest-Neighbor

We find the nearest value () to our target value . Then, we copy whatever is the label of to .

Some questions that you may have:

  1. What distance to use?
  2. How many samples should we base it on, data could be too noisy.