The same three neighbors can produce a different result when a stated toy weighting policy changes how votes add up.

highlighted = computed this step

The unweighted vote gives B

For query (0, 0), use the three displayed neighbors in the table. Without weights, class A has 1 vote and class B has 2 votes, so the unweighted winner is B.

A:1,B:2BA:1,\quad B:2\Rightarrow B
Distance-weighted voteAssigned inverse-squared-distance weights for one toy comparison.distance-weighted voteq=(0,0), k=3neighbor(x,y)classd^2weightvoteA1(1,0)A11AB1(2,0)B41/4BB2(0,2)B41/4BunweightedA: 1, B: 2winner BweightedA: 1, B: 1/2winner Aweights are 1/d^2 for this toy comparisonassigned inverse-squared-distance weights for a toy comparison; NOT training; NOT a probability; NOT a universal kNN rule

Assign inverse-squared-distance weights

This toy comparison uses assigned weight one over d^2. The A neighbor has d^2=1 and weight 1. Each B neighbor has d^2=4 and weight 1/4.

w=1d2w={1\over d^2}
Distance-weighted voteAssigned inverse-squared-distance weights for one toy comparison.distance-weighted voteq=(0,0), k=3neighbor(x,y)classd^2weightvoteA1(1,0)A11AB1(2,0)B41/4BB2(0,2)B41/4BunweightedA: 1, B: 2winner BweightedA: 1, B: 1/2winner Aweights are 1/d^2 for this toy comparisonassigned inverse-squared-distance weights for a toy comparison; NOT training; NOT a probability; NOT a universal kNN rule

Add weighted votes by class

The weighted total for A is 1. The weighted total for B is 1/4 + 1/4 = 1/2. The weighted winner is A.

A:1,B:1/4+1/4=1/2A:1,\quad B:1/4 + 1/4 = 1/2
Distance-weighted voteAssigned inverse-squared-distance weights for one toy comparison.distance-weighted voteq=(0,0), k=3neighbor(x,y)classd^2weightvoteA1(1,0)A11AB1(2,0)B41/4BB2(0,2)B41/4BunweightedA: 1, B: 2winner BweightedA: 1, B: 1/2winner Aweights are 1/d^2 for this toy comparisonassigned inverse-squared-distance weights for a toy comparison; NOT training; NOT a probability; NOT a universal kNN rule

What this policy is and is not

This is one exact toy comparison with assigned inverse-squared-distance weights. It is NOT training, NOT a probability, and NOT a universal kNN rule.

assigned weighted-vote policy on one toy query\text{assigned weighted-vote policy on one toy query}
Distance-weighted voteAssigned inverse-squared-distance weights for one toy comparison.distance-weighted voteq=(0,0), k=3neighbor(x,y)classd^2weightvoteA1(1,0)A11AB1(2,0)B41/4BB2(0,2)B41/4BunweightedA: 1, B: 2winner BweightedA: 1, B: 1/2winner Aweights are 1/d^2 for this toy comparisonassigned inverse-squared-distance weights for a toy comparison; NOT training; NOT a probability; NOT a universal kNN rule