A white query point at the origin is surrounded by cyan and orange training points. An expanding circle reveals neighbors in order of Euclidean distance, showing how K=3 yields a cyan prediction while K=5 flips it to orange, without altering the point's true label. The animation ties this flip to three design choices in KNN: distance metric, neighborhood size, and voting rule, then contrasts plain voting with distance weighting and explains why feature scaling must be fit only on training data. Useful for first-year AI students learning how KNN actually computes predictions.
Narrated · 16:9 · Preview before teaching · automatic layout checks do not establish subject accuracy
# Changing the neighborhood changes the KNN prediction A white query point sits at (0,0). Cyan training points lie at (1,0) and (0,1.2); orange points lie at (-1.4,0), (0,-1.6), and (1.8,0). Expand a circle from the query, revealing Euclidean distances 1, 1.2, 1.4, 1.6, and 1.8 in order. With K = 3, two cyan votes defeat one orange vote. With K = 5, three orange votes defeat two cyan votes. Change only the predicted outline of the query, not its unknown true label. Connect this example to the three design choices: distance metric, neighborhood size, and voting rule. Briefly contrast ordinary voting with distance weighting and explain why feature scaling must be fitted on training data. Use black backgrounds, fixed coordinates, and English narration synchronized to the expanding neighborhood. Useful for understanding what KNN actually computes. Audience: 一年级人工智能专业的学生