The GATE Grind

GATE 2024 DA – Question 63

Machine Learning · Supervised learning: classification · 2 marks · Numerical answer

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 ______.

Diagram for GATE 2024 DA question 63

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 5

Explanation

The distances from the diamond $(2, 1)$ are: circle $(1, 1)$: 1, circle $(1, 2)$: $\sqrt{2}$, square $(3, 2)$: $\sqrt{2}$, square $(2, 3)$: 2 and square $(3, 3)$: $\sqrt{5}$. For $k = 1$ the label is circle. For $k = 3$ the neighbours are the circle at distance 1, and then the circle and the square at distance $\sqrt{2}$, a tie, so the votes are 2 circles to 1 square (or 2 to 2 if the tie includes both), and the label is circle. For $k = 5$ all points count, 3 squares against 2 circles, so the label is square. The smallest odd $k$ is 5.

More Supervised learning: classification questions

All Supervised learning: classification questions →