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:2⇒B
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=d21
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/2
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.