cosine similarity
2
0
Entering edit mode
joe j ▴ 70
@joe-j-4637
Last seen 9.6 years ago
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 mdqc • 2.9k views
ADD COMMENT
0
Entering edit mode
@sean-davis-490
Last seen 3 months ago
United States
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 COMMENT
0
Entering edit mode
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 REPLY
0
Entering edit mode
Kevin Coombes ▴ 430
@kevin-coombes-3935
Last seen 17 months ago
United States
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 COMMENT
0
Entering edit mode
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 REPLY

Login before adding your answer.

Traffic: 732 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6