IAE Academy

GATE 2024 DA Q.63: solution and answer

GATE 2024 · DAQ.63 · 2 marks · NAT

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 in -nearest neighbor algorithm for which the diamond () shaped data point is assigned the label square is ______.

GATE 2024 DA question 63: A 2D grid plot with x-axis and y-axis both marked 1, 2, 3.Tap to open full size
Figure from the GATE 2024 DA paper. It is part of the question.
Figure description

A 2D grid plot with x-axis and y-axis both marked 1, 2, 3. Circles (class 1) at (1,1) and (1,2). Squares (class 2) at (2,3), (3,3) and (3,2). A diamond-shaped query point at (2,1). Each point is labelled with its coordinates.

Answer and solution

ANSWER

The minimum odd value of is .

Official answer: 5Source: Official answer key, GATE 2024 DA (IISc Bengaluru)

  1. Read the points off the plot: circles at and ; squares at , and ; the query (diamond) is at .

  2. Euclidean distances from : to it is ; to it is ; to it is ; to it is ; to it is .

  3. Order by distance: circle at ; circle and square tied at ; square at ; square at .

  4. : the single nearest point is the circle at , so the label is circle.

  5. : the three nearest points are , and . The tie at is fully included, because both tied points fall inside the three, so there is no cut-off ambiguity. That gives 2 circles and 1 square, so the majority is circle.

  6. : all five points vote, giving 2 circles and 3 squares, so the majority is square.

  7. The odd values and both give circle, and gives square, so the minimum odd that assigns the label square is .

KEY IDEA

In -NN, rank all training points by Euclidean distance from the query and take a majority vote among the nearest. Compute the distances once, then test each odd in turn.

WATCH OUT FOR

Counting only the two squares nearest to the query, or assuming that the square at is farther than the circle at . These two are tied at , so at both are included, and the circles still win 2 to 1. With 5 points in total, the only way for squares to win a majority is to use all of them.

From the GATE 2024 DA paper. Every question of this paper · Download the full paper · All 4 Logistic, k-NN, naive Bayes questions, with notes

More Logistic, k-NN, naive Bayes questions