Solved – K-Nearest-Neighbor classification with only distance/similarity matrices, is it possible

classificationdistributionshistogramrsupervised learning

I want to classify histograms/distributions using K-Nearest-Neighbor. I can measure distances/dissimilarities between the distributions (using euclidean distance, kullback-leibler divergence…), thus I can obtain distance matrices. I was wondering since Nearest Neighbors measure distances anyway, can I incorporate distance matrices directly into the algorithm?

Also if you know a function in R or python that already exists, I'm interested.
thank you

More details on my dataset: I have more than 100 observations that I want to classify in 2 classes (I have the labels) and all the features (4 features) are histograms (1 feature = 1 histogram).


UPDATE:

Using R: function "knn_dist" from "evclust" package

Best Answer

yes, it's possible because KNN finds the nearest neighbor, you already have distance/similarity matrix then the next step is to fix k value and then find the nearest value. Out of all the nearest neighbor take the majority vote and then check which class label it belongs.

Related Question