Skip to content

Instantly share code, notes, and snippets.

@timothyrenner
Created September 13, 2018 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothyrenner/caa33472d99712863b2c388e6d5ff58b to your computer and use it in GitHub Desktop.
Save timothyrenner/caa33472d99712863b2c388e6d5ff58b to your computer and use it in GitHub Desktop.
Average Agreement, Attempt 2
def average_agreement(list1, list2, max_depth):
### NEW CODE ###
# Empty lists evaluate to false.
if (not list1) or (not list2):
return 0.0
agreements = []
for depth in range(1, max_depth+1):
set1 = set(list1[:depth])
set2 = set(list2[:depth])
intersection = set1 & set2
agreements.append(2 * len(intersection) / (len(set1) + len(set2)))
return sum(agreements) / len(agreements)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment