GATE DA 2024 · k-Nearest Neighbour (k-NN)

NAT · 2 marks · Problem ML-KNN-0012

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

Numerical answer (NAT).

Solve it on GATE DA practice →More Supervised Learning — Classification problems

Show the worked solutionFrom the figure: circles at \((1,1),(1,2)\); squares at \((2,3),(3,3),(3,2)\); the diamond is at \((2,1)\).Distances from \((2,1)\): \((1,1)\): \(1\) (circle); \((1,2)\): \(\sqrt2\) (circle); \((3,2)\): \(\sqrt2\) (square); \((2,3)\): \(2\) (square); \((3,3)\): \(\sqrt5\) (square).\(k=1\): circle. \(k=3\): the three nearest are \((1,1),(1,2),(3,2)\): 2 circles, 1 square, so circle.\(k=5\): 2 circles, 3 squares, so square.Answer: 5

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com