An ES6 Javascript example illustrating the K-Nearest-Neighbor (kNN) algorithm used in machine learning. Written in ES6 JavaScript.
The Premise is as follows: Given a set of data points that identify characteristics (rooms, size) of three different types of residences (apartment, condo or house), if you have a new residence of an unknown type, you can 'teach' your machine through code to identify the residence based upon its known size and rooms, by comparing this data to it's closest 'neighbors" that are similar in size and room number.
In this demo, the residence of unknown type is compared to three neighbors that are similar to it. Based upon its closest neighbors, we can make a good guess on what the unknown residence actually is.
To view this example, browse to https://eapostol.github.io/k-nearest-neighbor-es6/ in Chrome. Open up the Dev tools, and observe the output in the console while the data point of unknown type is displayed on the screen. The circular edge represents the distance required to measure against its three closest neighbours.