Search code examples
machine-learningclassificationknn

How would a 1-nearest neighbour classifier based on the Euclidean distance classify the observation


What would be an answer to this?

Consider a dataset D that contains only two observations 𝐱1=(1,1) and 𝐱2=(−1,−1) . Suppose that the class of the first observation is 𝑦1=0 and that the class of the second observation is 𝑦2=1 . How would a 1-nearest neighbour classifier based on the Euclidean distance classify the observation 𝐱=(2,3) ? What are the distances between this new observation and each observation in the dataset? [0.5 marks out of 5]


Solution

  • Since x is closer to x_1 than to x_2 (I'll let you compute the distances yourself), the classifier would assign the class of x_1 to x, i.e. 0