Using JavaScript, we implement the k-Nearest Neighbors algorithm from the bottom up.

Demo and Codebase

If you would like to play with the k-Nearest Neighbors algorithm in your browser, try out the visually interactive demo. All of the code for the demo is hosted on GitHub. Stars are always appreciated.

The Scenario

Say you have a garden that is host to many different kinds of plants. Each plant’s location in the garden is based on two of its features. The west to east direction of the garden corresponds to the diameter of the plant’s flower while the south to north direction relates to the length of the plant’s leaf. Each plant in the garden has been carefully labeled with a small tag stuck in the dirt located near its base.

Source: k-Nearest Neighbors from Scratch by David Lettier

Categories: Uncategorized

Related Posts


Cancer Gene Trust Search

Source: Cancer Gene Trust Search Related PostsScientists Find Form of Crispr Gene Editing With New Capabilities – The New York TimesPills of Science – 1 WeekDNA Extraction Virtual LabDNA Extraction Virtual LabCancer Gene Panels


The Long-Term Stock Exchange Is Worth a Shot – Bloomberg

Silicon Valley venture capitalists are shaking things up with “tenure voting.” Source: The Long-Term Stock Exchange Is Worth a Shot – Bloomberg Related PostsThe Right Way to Grant Equity to Your EmployeesHow CEO Anne Wojcicki Read more…


How to Be a Know-It-All | The New Yorker

What you learn from the Very Short Introduction series. Source: How to Be a Know-It-All | The New Yorker Related PostsIntroduction to Scientific Python – StanfordDeep LearningIntroduction to Biostatistics and BioinformaticsIntroduction to Biostatistics and BioinformaticsThe Read more…