MathOverflow is a question and answer site for professional mathematicians. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to calculate the similarity between two sets using Jaccard but temper the results using the relative frequency of each item within a corpus.

Jaccard is defined as the magnitude of the intersection of the two sets divided by the magnitude of the union of them both.

$jaccard(A, B) = \frac{|A \bigcap B|}{ |A\bigcup B|}$

If I use inverse document frequency (the log of the number of documents divided by the frequency of the item) ...

$idf(i) = log\frac{| D |}{f(i)+1}$

$|D|$ is the number of documents

$|f(i)|$ is the frequency of the item in the documents.

... can I define my weighted Jaccard similarity function as the sum of the IDFs of the items in the intersections divided by the sum of the IDFs of the union? (Sorry describing this in LaTeX reaches the limits of my knowledge of notation.) Will this scale the similarity appropriately? Are a collection of weights better suited to a cosine similarity?

share|cite|improve this question
Hi Tom---mathoverflow might not be the correct site for your question---you might get more feedback from math.stackexchange or the stats stackexchange etc. – Suvrit Mar 2 '13 at 3:30
Will do. Thanks. – Tom Martin Mar 6 '13 at 11:26

The following paper from experts at Google:

Defines Weighted Jaccard between two vectors with non-negative entries as:

enter image description here

Using the Inverse Document Frequency is interesting, but I am not sure you could really call this a weighted Jaccard?

Here is another paper on a related topic as well:

Hope this helps!

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.