## Implementing the popular classification algorithms in Golang from scratch

KNN stands for k-nearest neighbor and is an algorithm based on a simple idea and can be used for both classification and regression. The boundary becomes smoother with increasing value of k. With k increasing to infinity it finally becomes all blue or all red depending on the total majority.

KNN works by iterating through the data and calculating the Euclidean distance and for the k nearest neighbor of the given point, the point falls into one of several categories.

Okay, now that you’re familiar with how the KNN algorithm works in theory, let’s dig into the code.

I have based my code on a previous plotting library I created which will make it easy to implement and plot. The basic interface is a point with three variables, the x and y coordinates and the boolean, which represents the category.