When the nearest is wrong
Show on a big screenThe classifier gets four of today's five kites right. Kite A2 is not one of them.
- Kite A2 checks in at 8 span, 4 tail.
- Its nearest example is R5, one square away: dancer.
classify(A2, register)returns dancer.- The judge's true word for A2 is steady. The measurement was right; the word was wrong.
The rule
Step the wrong kite through your own function. The nearest example truly is nearest, but it carries the wrong word. The code is right; the register held no steady kite nearer.
One square away means squared distance 1, one step. Trace the walk, and every comparison is correct. R5 really is one square away. R5 is closer than every other example. The function measured correctly and returned the nearest example's word.
This rule is k-nearest neighbour with k = 1. Here k is how many nearest examples decide. So one nearest example decides. The three nearest to A2 are all dancers. So a vote of three cannot fix it.
The register holds eight shop-bought kites. A2 is homemade. A2 sits one square from a shop-bought dancer. That dancer's word becomes A2's word.
Follow every comparison until the wrong example is chosen.
Loading lab…
Read the register tally beside the table: four steady, four dancer.
Try the lab to finish this lesson.