Our first learning system will be the k-nearest neighbors (kNN) classifier. I will describe how the classifier makes predictions, the important hyperparameters it uses, and the problems that are faced by the classifier. Throughout, I will be using the classifier to predict species of iris flowers. So, let's go ahead and start a Jupyter Notebook for this classifier:
- The first thing we're going to do is load in the dataset and other required functions, as follows:
The iris dataset is provided with sklearn. It is one of their example datasets, and is well known.
- Then, we will load in an object that contains the iris data and save that into Python objects:
- Then, we will divide the dataset into training and test data by using the following lines of code:
Here are the first five rows of the training data:
Here are the first five labels...