From the course: Supervised Learning Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

How to assemble a KNN model

How to assemble a KNN model - Python Tutorial

From the course: Supervised Learning Essential Training

Start my 1-month free trial

How to assemble a KNN model

- [Instructor] KNNs are one of the simplest types of classification models that you can use with nearly no prior knowledge of the data. The basic format of a KNN is that it works to find the distance between the query and all other examples in the data. We select the specified number of examples, or K, closest to the query. And the model votes on the most frequent label for classification and averages the label for regression. Once these predictions are made, we measure how well our model performs. We can break the K-nearest neighbors algorithm up into three steps; calculating the distance, getting the K-closest instances, and making predictions. The first step involves calculating the differences between two rows in a dataset. Take a minute to understand the kind of data you're looking at and think back to the different types of distance measures. If you're having trouble deciding, you can start with Euclidean…

Contents