cosine

How to match Tagged items based on "similarity"

I have a real question. I have a database with the schema as follows: item id description other junk tag id name item2tag item_id tag_id count Basically, each item is tagged as up to 10 things, with varying counts. There are 50,000 items and 50,000 tags, and about 500,000 entries in items2tag. I'd like to find, given one...

Cosine similarity of vectors

Hi how do i find the cosine similarity between vectors. I need to find the similarity to measure the relatedness between two lines of text.Can someone help me with the code.what java classes and methods to use. For example i ve two sentences like 1.system for user interface and 2.user interface machine and their respective vectors afte...

get cosine similarity between two documents in lucene

Hi i have built an index in Lucene. I want without specifying a query, just to get a score (cosine similarity or another distance?) between two documents in the index. For example i am getting from previously opened IndexReader ir the documents with ids 2 and 4. Document d1 = ir.document(2); Document d2 = ir.document(4); How can i ge...

Compare Two Vectors (Java)

Hi Currently I have two larger vectors of 50+ strings I want to be able to compare these two Vectors and work out how similar they are. I think I need to use Cosine similarity? Does anyone know of any methods that take in two Java Vectors and gives a value between 0 and 1 as to how similar they are? Thanks Phil ...

Cosine Similarity

Hi All, Thank you all great guys here for helping people like me :) I just need small hint .... I calculated tf/idf values of two documents. Following is the tf/idf values 1.txt 0.0 0.5 2.txt 0.0 0.5 The documents are like 1.txt = > dog cat 2.txt = > cat elephant As now I have tf/idf values. Can any body tell me how to use these valu...

Using the Cosine law to calculate distance between 2 points in Objective C?

Hi I get some GPS coordinates from Google Maps and I need to find the distance between them using Objective C. I have implemented the formula but I get results that are way to big. I have tested the values from Google Maps by passing them back into Google Earth and a Geocoding service on the internet and everything checks out. Im now b...

How do you efficiently implement a document similarity search system?

How do you implement a "similar items" system for items described by a set of tags? In my database, I have three tables, Article, ArticleTag and Tag. Each Article is related to a number of Tags via a many-to-many relationship. For each Article i want to find the five most similar articles to implement a "if you like this article you wil...

Java Math.cos() Method Does Not Return 0 When Expected

Using Java on a Windows 7 PC (not sure if that matters) and calling Math.cos() on values that should return 0 (like pi/2) instead returns small values, but small values that, unless I'm misunderstanding, are much greater than 1 ulp off from zero. Math.cos(Math.PI/2) = 6.123233995736766E-17 Math.ulp(Math.cos(Math.PI/2)) = 1.2325951644078...

Find cosine similarity in R

I'm wondering if there is a built in function in R that can find the cosine similarity (or cosine distance) between two arrays? Currently, I implemented my own function, but I can't help but think that R should already come with one :) Thanks, Derek ...

Cosine Similarity Measure: Multiple results

My program uses clustering to produce subsets of similar items and then uses the cosine similarity measure as a method of determining how similar the clusters are. For instance if user 1 has 3 clusters and user 2 has 3 clusters then every cluster is compared against each other, 9 results using the cosine similarity measure will be produc...

How can I work around the fact that in C++, sin(M_PI) is not 0?

In C++, const double Pi = 3.14159265; cout << sin(Pi); // displays: 3.58979e-009 it SHOULD display the number zero I understand this is because Pi is being approximated, but is there any way I can have a value of Pi hardcoded into my program that will return 0 for sin(Pi)? (a different constant maybe?) In c...

How do I calculate a cosinor analysis in SPSS, HELP!

How can I put this into spss??? http://www.cbi.dongnocchi.it/glossary/Cosinor.html I am trying to calculate the MESOR for a cyclic pattern of circadian rhythm. ...

Very fast document similarity

Hello, I am trying to determine document similarity between a single document and each of a large number of documents (n ~= 1 million) as quickly as possible. More specifically, the documents I'm comparing are e-mails; they are grouped (i.e., there are folders or tags) and I'd like to determine which group is most appropriate for a new...

about cosine similarity

hi i m finding cosine similarity between documents ..i did like dis D1=(8,0,0,1) where 8,0,0,1 are the tf-idf scores of the terms t1, t2, t3 , t4 D2=(7,0,0,1) cos(theta) = (56 + 0 + 0 + 1) / sqrt(64 + 49) sqrt(1 +1 ) which comes out to be cos(theta)= 5 now what do i evaluate from this value...i dont get it wat does cos(theta)=5 s...

statistical cosinor analysis,

Hey i am trying to calculate a cosinor analysis in statistica but am at a loss as to how to do so. I need to calculate the MESOR, AMPLITUDE, and ACROPHASE of ciracadian rhythm data. http://www.wepapers.com/Papers/73565/Cosinor_analysis_of_accident_risk_using__SPSS%27s_regression_procedures.ppt there is a link that shows how to do it, t...

cos result incorrect

I import "math.h". I can use the cos function, but when I execute cos(0.321139585333178) the result is 0.948876 If I use the calculator in Mac or use a normal calculator, the result is 0.999984292347418 Can anyone help me to solve that problem? ...

Accuracy of Math.Sin() and Math.Cos() in C#

I am terribly annoyed by the inaccuracy of the intrinsic trig functions in the CLR. It is well know that Math.Sin(Math.PI)=0.00000000000000012246063538223773 instead of 0. Something similar happens with Math.Cos(Math.PI/2). But when I am doing a long series of calculations that on special cases evaluate to Math.Sin(Math.PI/2+x)-M...

Adjusted Cosine Similarity

Hello there. Can you help me, please. I was confused to make PHP code about adjusted cosine similarity. I have build data like this : $data[UserID][ItemID] = Rating data example : $data[1][1] = 5; $data[1][2] = 3; $data[1][3] = 4; $data[2][1] = 3; $data[2][2] = 2; $data[2][4] = 3; $data[2][5] = 3; $data[3][1] = 4; $data[3][3] = 3; $d...

Java Cosine Similarity Error

I am using getSimilarity(String s1, String s2) from the library : uk.ac.shef.wit.simmetrics.similaritymetrics.CosineSimilarity; to get the cosine similarity between two strings. Well the problem is that when I pass two strings to compare from the xml directly it just hangs the programs doesn't exit. The same thing I do by assigning the ...

How to use a Sine / Cosine wave to return an oscillating number

I'm new to Java programming, I am programming Java 1.6 with Android. I have a simple function that makes a number go up and down between 0 and 200. I would like to put this into a Sine function but keep getting errors with what I've been trying. I want my program to update an int (Number1) via a sine wave y axis. Any ideas change the...