I am new to R and Machine Learning. I am running a KNN classification using the Euclidian distance. I was wondering how can I use cosine and jaccard distance instead of Euclidian in R? Are there any packages I can use ? Thank you
Asked
Active
Viewed 1,455 times
1 Answers
0
first of all what you can do is run from within an R-session
library(sos)
findFn("knn", maxPages=10, sortby="MaxScore")
to search for knn packages by maxscore ( you can adjust the parameters accordingly ).
If you don't find a package that offers the cosine or jaccard distance, then I would suggest to first compute the distance matrix and then give this as input to the knn.
There are some packages like kNN or FastKnn which accept a distance matrix as input ( you can google this using : "distance matrix knn r" ).
Lastly the KernelKnn allows the computation of the jaccard distance but only for binary data (I'm the author, you can have a look to the other distance metrics too).
I hope it helps.

lampros
- 581
- 5
- 12