April 2018
Beginner to intermediate
282 pages
6h 52m
English
Let’s see a quick example of the k-nearest neighbor (k-NN) algorithm, which works both for classification and regression problems. When an algorithm scores a new feature vector, it checks the k nearest neighbors and outputs a result. If it's a classification problem, a prediction is made using a majority vote; if it's a regression problem, then the average of the values is used as a prediction.
Let's understand this better by working on an example classification problem. First, you will create a sample dataset and you will examine the k-NN algorithm in terms of time spent for training and scoring.
Just to make things easier, the following function will be used to measure the time spent on a given ...