Implementing k-Nearest Neighbors

Classification example. K=3 will choose triangle, while K=7 chooses the stars.
  1. Calculate Euclidean Distance
  2. Get Nearest Neighbors (Fit)
  3. Make Predictions
  4. Display!
Euclidean Distance Example from my Github
Fitting the data
The prediction section ties in the Euclidean Distance and Fit data
Comparing sklearn model with the one written above
Output of sklearn, then self built k-NN



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ashley Gaskins

Ashley Gaskins

Data Science student looking for Data Science/Engineering opportunities!