Question: cosine similarity
0
8.3 years ago by
joe j70
joe j70 wrote:
Dear All, I am after a package that would calculate the uncentred correlation (or cosine similarity; http://en.wikipedia.org/wiki/Cosine_similarity) between pairs of observations. I know that bioconductor has packages that compute distance measures such as mahalanobis distance (the package mdqc does this). Is there any package that calculates cosine similarity? Regards, Joe.
mdqc • 2.1k views
modified 8.3 years ago by Kevin Coombes430 • written 8.3 years ago by joe j70
0
8.3 years ago by
Sean Davis21k
United States
Sean Davis21k wrote:
Hi, Joe. Not positive if this is what you want, but you might look at the cosine() function in the lsa package. Sean On Mon, Jun 27, 2011 at 8:24 AM, joe j <joe.stata at="" gmail.com=""> wrote: > Dear All, > > I am after a package that would calculate the uncentred correlation > (or cosine similarity; http://en.wikipedia.org/wiki/Cosine_similarity) > between pairs of observations. I know that bioconductor has packages > that compute distance measures such as mahalanobis distance (the > package mdqc does this). Is there any package that calculates cosine > similarity? > > Regards, > Joe. > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >
Hi, I am not sure if there is a package for this but assuming that your data is A=[a1,a2,a3,a4...,an] in rows. Then, %A=matrix(rnorm(50),nr=5) %testing case 1 %A=matrix(rep(1,100),nr=5) %testing case 2 myDist=function(A){ intermediateRes1=A%*%t(A) myVec=sqrt(diag( intermediateRes1)) intermediateRes2=myVec%*%t(myVec) myResult=as.dist(intermediateRes1/intermediateRes2) return(myResult) } should do what you want. cheers, Achilleas On Mon, Jun 27, 2011 at 8:35 AM, Sean Davis <sdavis2@mail.nih.gov> wrote: > Hi, Joe. > > Not positive if this is what you want, but you might look at the > cosine() function in the lsa package. > > Sean > > On Mon, Jun 27, 2011 at 8:24 AM, joe j <joe.stata@gmail.com> wrote: > > Dear All, > > > > I am after a package that would calculate the uncentred correlation > > (or cosine similarity; http://en.wikipedia.org/wiki/Cosine_similarity) > > between pairs of observations. I know that bioconductor has packages > > that compute distance measures such as mahalanobis distance (the > > package mdqc does this). Is there any package that calculates cosine > > similarity? > > > > Regards, > > Joe. > > > > _______________________________________________ > > Bioconductor mailing list > > Bioconductor@r-project.org > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > _______________________________________________ > Bioconductor mailing list > Bioconductor@r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > [[alternative HTML version deleted]]
0
8.3 years ago by
Kevin Coombes430
United States
Kevin Coombes430 wrote:
Check the "distanceMatrix" funciton in the "ClassDiscovery" package that is part of OOMPA. R repository located at http://bioinformatics.mdanderson.org/OOMPA Instructions for installation and some documentation at http://bioinformatics.mdanderson.org/Software/OOMPA -- Kevin On 6/27/2011 7:24 AM, joe j wrote: > Dear All, > > I am after a package that would calculate the uncentred correlation > (or cosine similarity; http://en.wikipedia.org/wiki/Cosine_similarity) > between pairs of observations. I know that bioconductor has packages > that compute distance measures such as mahalanobis distance (the > package mdqc does this). Is there any package that calculates cosine > similarity? > > Regards, > Joe. > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor