opnsense-ports/math/py-annoy/files/test-load.py
Franco Fichtner d6d6c1082e */*: sync with upstream
Taken from: FreeBSD
2023-01-12 13:30:53 +01:00

7 lines
243 B
Python

from annoy import AnnoyIndex
f = 40 # Length of item vector that will be indexed
u = AnnoyIndex(f, 'angular')
u.load('test.ann') # super fast, will just mmap the file
print(u.get_nns_by_item(0, 1000)) # will find the 1000 nearest neighbors