Skip to content

k-nearest neighbours

learning

Level 1 of 3

Also called k-NN and Nearest neighbour classification.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from k-nearest neighbours's own run on the numbers shown.

choose one

question 1

A new point at 10 across, 10 up, among 6 6 s, 10 4 t, 8 5 s, 1 6 c and 4 0 t, with k = 2. How many distances are measured?

051015051015
the answer, and why

the answer is A

One for each of the 5 points, before any vote.

if you chose another

  • That counts only the 2 that vote.
  • That counts every step of the run, the start, the ring, the vote and the verdict too.
  • That is the nearest point alone; it is found only after all 5 are measured.

new numbersthe test page's numbers

question 2

A new point at 2 across, 1 up, among 5 10 s, 3 2 c, 0 2 t, 7 2 c, 5 2 t and 0 7 t, with k = 4. How many circles are inside the ring?

0510-50510
the answer, and why

the answer is D

The ring of the 4 nearest reaches 5.1 and takes in both circles, at 3, 2 and 7, 2, 1.41 and 5.1 away.

if you chose another

  • There are only 2 circles among the points.
  • That leaves out the circle at 7, 2.
  • The nearest point is a circle.

new numbersthe test page's numbers

question 3

A new point at 4 across, 2 up, among 10 4 c, 10 6 t, 7 0 t, 2 7 c, 9 1 s, 5 2 t and 3 8 s, with k = 4. How far does the ring reach?

05100510
the answer, and why

the answer is C

It just reaches the farthest of the 4 nearest, the circle at 2, 7: 2 squared plus 5 squared is 29, and its root is about 5.39.

if you chose another

  • That is the second nearest, the triangle at 7, 0.
  • That is the square at 3, 8, the nearest outside the ring.
  • That is the farthest point of all, the triangle at 10, 6.

new numbersthe test page's numbers