KNN K Nearest Neighbors Algorithm
KNN K Nearest Neighbors Algorithm
KNN may be used to predict classification and regression issues. However, in the industry, it is more
commonly utilized in categorization issues. We typically look at three essential elements while
evaluating any technique:
2. Calculation time
3. Predictive Power
Advantage Of KNN
2. There’s no need to build a model, tune several parameters, or make additional assumptions.
3. The algorithm is versatile. It can be used for classification, regression, and search
Disadvantage Of KNN
3. For each example in the data 3.1 Calculate the distance between the query example and the current example
from the data.
3.2 Add the distance and the index of the example to an ordered collection
4. Sort the ordered collection of distances and indices from smallest to largest (in ascending order) by the
distances
7. If regression, return the mean of the K labels 8. If classification, return the mode of the K labels