KNN is the method that requires the selection of several nearest neighbors and a distance metric at the same time. It can predict both discrete and continuous attributes of a dataset.
A distance function is used here to find the similarity of two or more attributes, which will help in further analysis.