Posts

Showing posts from February, 2018

Classification using K-Nearest Neighbor Classifier with Scikit Learn

Image
K-NN is a very simple machine learning algorithm which can classify a point based on other nearest points. Let's take an example, if you see the below image. We have set k = 3, this means that we will classify a point based on the nearest three points, in this case two of the three points are orange points therefore the unknown point (blue point) will be classified as an orange point. OK, let's do a real classification task, in this example I am going to classify the most popular iris flower data set. In this data set there are samples of three different types of Iris flower. Those are Versicolor, Verginica, Setosa and I am going to build a model that is capable of classifying a new flower into one of these categories.  Let's code, Step 1 - Import the necessary libraries and load the data (I am going to make use of Scikit Learn's Iris Data set) Let's understand the data set, this data set consist of 150 records (Every Iris type has 50 r...