Skip to content
Permalink
57a892325e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
14 lines (10 sloc) 350 Bytes
def jaccard(list_a, list_b):
"""
Calculates the jaccard index from two python lists.
:param list_a: First list
:param list_b: Other list
:return: The jaccard index
"""
union_count = len(set(list_a + list_b))
intersection_count = len(set(list_a).intersection(set(list_b)))
return intersection_count/union_count