The idea behind KNN is relatively straightforward. Given the value of a new particular data point, look at the KNN to the point, and assign a label to the point, depending on the labels of those k neighbors, where k is a parameter of the algorithm.
There is no model as such constructed in this scenario; the algorithm merely looks at all the distances between our new point and all the other data points in the dataset, and in what follows, we are going to make use of a famous dataset that consists of three types of iris flowers: iris setosa, iris virginica, and iris versicolor. For each of these labels, the features are petal length, petal width, sepal length, and sepal width. For diagrams showing this dataset, see ...