A nearest-neighbor vote can end with equal class counts. This lesson shows an exact tied vote and names the required policy boundary.

highlighted = computed this step

Four nearest rows

This shown query uses k=4. The four displayed nearest rows have squared distances 1, 1, 4, and 4.

k=4,d2=[1,1,4,4]k=4,\quad d^2=[1,1,4,4]
Tied neighbor voteThe nearest displayed neighbors split evenly by class.tied nearest-neighbor voteq=(0,0), k=4ranki(x,y)classd^2nearest10(-1,0)A1yes21(1,0)B1yes32(0,-2)A4yes43(0,2)B4yesvote countA: 2B: 2no class winsoutput=tie policy requiredvote alone has no winner; state a tie policy before output

The vote is tied

Among those neighbors, class A has 2 votes and class B has 2 votes. No class wins from the vote alone.

A:2,B:2A:2,\quad B:2
Tied neighbor voteThe nearest displayed neighbors split evenly by class.tied nearest-neighbor voteq=(0,0), k=4ranki(x,y)classd^2nearest10(-1,0)A1yes21(1,0)B1yes32(0,-2)A4yes43(0,2)B4yesvote countA: 2B: 2no class winsoutput=tie policy requiredvote alone has no winner; state a tie policy before output

State the policy

Because the vote is tied, the displayed output is tie policy required. A class label would need a stated tie policy first.

output=tie policy required\text{output}=\text{tie policy required}
Tied neighbor voteThe nearest displayed neighbors split evenly by class.tied nearest-neighbor voteq=(0,0), k=4ranki(x,y)classd^2nearest10(-1,0)A1yes21(1,0)B1yes32(0,-2)A4yes43(0,2)B4yesvote countA: 2B: 2no class winsoutput=tie policy requiredvote alone has no winner; state a tie policy before output