Question: cosine similarity
0
gravatar for joe j
8.2 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
ADD COMMENTlink modified 8.2 years ago by Kevin Coombes430 • written 8.2 years ago by joe j70
Answer: cosine similarity
0
gravatar for Sean Davis
8.2 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 >
ADD COMMENTlink written 8.2 years ago by Sean Davis21k
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]]
ADD REPLYlink written 8.2 years ago by Achilleas Pitsillides170
Answer: cosine similarity
0
gravatar for Kevin Coombes
8.2 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
ADD COMMENTlink written 8.2 years ago by Kevin Coombes430
Thanks a lot Achilleas, Kevin, Kevin, "distanceMatrix" funciton works great, although distance is calculated across columns-but I guess a simple transpose would do the trick. I compared the result (for two rows) with the function written by Achilleas. They seem to be identical except that one is distance, the other is correlation. Thanks very much, again! Jojo On Mon, Jun 27, 2011 at 4:27 PM, Kevin R. Coombes <kevin.r.coombes at="" gmail.com=""> 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 >
ADD REPLYlink written 8.2 years ago by joe j70
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 223 users visited in the last hour