Nearest Neighbors
Nearest Neighbors: Distance Between Examples, Nearest Neighbors.
Updated
- Distance Between Examples (Apprentice): Two examples become points when each feature is a direction, the straight-line (Euclidean) distance between them comes from the Pythagorean theorem and math.dist works it out for any number of features, and a feature measured in big units, like grams, swamps one scored from 0 to 10 until the features are put on a common scale.
- Nearest Neighbors (Journeyman): A nearest neighbors classifier guesses a new example's class by finding the k training examples closest to it and letting them vote, with KNeighborsClassifier(n_neighbors=5) storing the training rows instead of learning a rule, a small k following every quirk, a large k blurring the classes together, and a tied vote, which in the lesson's run went to the class listed first.