KNN Animation

This week in NOC we are looking at classification and regression. I was interested in getting a better sense of how classification changes with K’s change. I also wondered if KNN could be used an an animation technique to make interesting graphics.

I worked with Shiffman’s KNN P5 example. I changed the code to update the K with every frame. I played with maxing K at variable numbers. The system would stop working with about K over 50. I also changed the slider so that the user can only see one variable at a time—A, B, or C.

See it live at lmj.io/projects/noc/knn/ and here’s the code on github.

Here are animations of A, B, C (in that order) set at K of 10

a_2.mp4

b_2.mp4

c_2.mp4

Here are animations of A, B in a sketch set at K of 50. Interesting how A completely blacked out B.

ab_2.mp4

bb_2.mp4