A nearest neighbor algorithm classifies a data instance based on its neighbors. The class of a data instance determined by the k-nearest neighbors algorithm is the class with the highest representation among the k-closest neighbors.
In this chapter, we will cover the following topics:
- How to implement the basics of the k-NN algorithm using the example of Mary and her temperature preferences
- How to choose a correct k value so that the algorithm can perform correctly and with the highest degree of accuracy using the example of a map of Italy
- How to rescale values and prepare them for the k-NN algorithm using the example of house preferences
- How to choose a good metric to measure distances between data points
- How to eliminate irrelevant dimensions in higher-dimensional space to ensure that the algorithm performs accurately using the text classification example