1
$\begingroup$

Given this dataset :

name1,name2,distance
a,b,1
a,c,5
b,c,8

If k=1 is the following correct :

a,b nearest neighbour is b,c
a,c nearest neighbour is b,c
b,c nearest neighbour is a,c

or

"a" nearest neighbor is b since distance(a,b) is 1 
"b" nearest neighbor is a since distance(a,b) is 1 
"c" nearest neighbor is a since distance(a,c) is 5 
$\endgroup$
1
  • 2
    $\begingroup$ Pedantry alert: If your measure is symmetric, i.e., $d(a, b) = d(b, a)$ then your measure violates the triangle inequality, since $6 = d(b,a) + d(a,c) < d(b, c) = 8$, and isn't actually a valid distance, which can cause problems. $\endgroup$
    – alto
    Commented May 15, 2014 at 21:01

1 Answer 1

2
$\begingroup$

The idea of k-nearest neigbors is which other point(s) are closest according to some distance metric. The following holds for k=1.

The distance between $a$ and $b$ is 1, the distance between $a$ and $c$ is 5. Thus the nearest neighbor to $a$ is $b$.

Similarly, the nearest neighbor to $b$ is $a$ since the distance between $b$ and $c$ is 8.

The nearest neighbor to $c$ is $a$ since the distance between $c$ and $a$ is 5 which is less than the distance between $c$ and $b$ which is 8.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.