Prelude

Uniformly Continuous Targets

“Children need continuity as they grow and learn”

- Thoman Menino, Former Mayor of Boston.

 “One of these things is not like the others,

One of these things doesn't belong,

Can you tell which thing is not like the others by the time I finish this song?”

Along with a set of four objects, this song plays during an episode of Sesame Street, the famous children show. For example, an apple, a cup of ice-cream, a burger sandwich, and a sock are shown, and the children watching the show would scream out: the sock! While it seems like a trivial answer, it's worth taking a deeper look into what could be going on inside a child's mind during the very short interval between the moment they hear the song and see the object, and when they scream out the answer.

Figure P1-1: A child's Brain's ability to capture similarity allows it to catch the out-of-group object
Description: CH05Preload_FIG_1_G_ML

5 K-Nearest Neighbors Method

5.1       A Basic K-NN Classifier

5.1.1   The “Can I eat that?” App

5.1.2   The Intuition Behind k-NN

5.1.3   How to Measure Similarity?

5.1.4   k-NN in Action

5.1.5   Boosting Performance with NumPy

5.2       A Better k-NN Classifier

5.2.1   Doing Faster Neighborhood Search Using K-d trees

5.2.2   Using k-d Trees with scikit-learn

5.2.3   Tuning the Value of k

5.2.4   Choosing the Metric

5.3       Is K-nn Reliable?

5.3.1   The Bayes Optimal Classifier

5.3.2   Reliability of 1-NN