Skip to content

Instantly share code, notes, and snippets.

@herrbuerger
Created May 3, 2014 07:38
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 herrbuerger/6cbeada92901a282c957 to your computer and use it in GitHub Desktop.
Save herrbuerger/6cbeada92901a282c957 to your computer and use it in GitHub Desktop.
from annoy import AnnoyIndex
a = AnnoyIndex(3)
a.add_item(10, [1, 0, 0])
a.add_item(11, [0, 1, 0])
a.add_item(13, [0, 0, 1])
a.build(-1)
print a.get_nns_by_item(13, 10)
print a.get_nns_by_item(1, 10)
# [13, 0, 1, 2, 3, 4, 5, 6, 7, 8]
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment