GATE DA 2024 | Question 63

NAT · 2 marks

Given the two-dimensional dataset consisting of 5 data points from two classes (circles and squares) and assume that the Euclidean distance is used to measure the distance between two points. The minimum odd value of \(k\) in \(k\)-nearest neighbor algorithm for which the diamond (\(\diamond\)) shaped data point is assigned the label square is ______.

Grid with both axes marked 1 to 3: filled circles at (1, 1) and (1, 2), filled squares at (2, 3), (3, 3) and (3, 2), and a hollow diamond at (2, 1), each point labelled with its coordinates.

Answer

5

Explanation

Distances from the diamond at (2, 1):

  • circle (1, 1): 1
  • circle (1, 2) and square (3, 2): \(\sqrt{2} \approx 1.41\) each
  • square (2, 3): 2
  • square (3, 3): \(\sqrt{5} \approx 2.24\)

Now try the odd values of \(k\) in turn:

  • \(k = 1\): the nearest point is a circle, so the label is circle.
  • \(k = 3\): two circles and one square; the tie at \(\sqrt{2}\) does not matter because both tied points are among the three. The label is circle.
  • \(k = 5\): all five points vote, 3 squares to 2 circles, so the label is square.

Answer: 5