After the nearest rows are fixed, the class is assigned by a strict majority vote. Odd k keeps the displayed rule deterministic.

highlighted = computed this step

Majority vote

The k nearest labels are A, A, and A. The majority vote assigns class A to the query.

vote=A\text{vote}=A
Majority voteThe selected nearest rows determine the class by exact majority.Majority votequery=(1,1), k=3, vote=Ai(x,y)classd^2nearesttie-break0(0,0)A21low i1(2,0)A22low i2(0,2)A23low i3(3,3)B8low i4(3,1)B4low i5(1,3)B4low idistances use d^2 only; equal d^2 sorts by lowest training index

Why k is odd

This surface requires odd k. With k=3, a strict majority exists for the displayed nearest labels.

k=3 is oddk=3\text{ is odd}
Majority voteThe selected nearest rows determine the class by exact majority.Majority votequery=(1,1), k=3, vote=Ai(x,y)classd^2nearesttie-break0(0,0)A21low i1(2,0)A22low i2(0,2)A23low i3(3,3)B8low i4(3,1)B4low i5(1,3)B4low idistances use d^2 only; equal d^2 sorts by lowest training index

Summary

The assigned class is A because 3 nearest labels vote A. A changed authored vote is rejected.

assigned class=A\text{assigned class}=A
Majority voteThe selected nearest rows determine the class by exact majority.Majority votequery=(1,1), k=3, vote=Ai(x,y)classd^2nearesttie-break0(0,0)A21low i1(2,0)A22low i2(0,2)A23low i3(3,3)B8low i4(3,1)B4low i5(1,3)B4low idistances use d^2 only; equal d^2 sorts by lowest training index