Similarity functions for the KNN method