Calmcode - annoy: final features

Extra Features of Annoy

1 2 3 4 5 6 7 8

The full annoy API is defined on the github page.

If you want to pick up the full notebook of everything done here you can find it over at the calmcode notebook repo.


Metrics can be angular, euclidean, manhattan, hamming, or dot.


If you want to save and load from disk you can use this code;

columns = 2
vecs = np.concatenate([
    np.random.normal(-1, 1, (5000, columns)),
    np.random.normal(0, 0.5, (5000, columns)),

metric = 'euclidean'

annoy = AnnoyIndex(columns, metric)
for i in range(vecs.shape[0]):
    annoy.add_item(i, vecs[i, :])

# here we save the annoy index'test.ann')

# next we make a new object with the same settings
annoy_from_disk = AnnoyIndex(columns, metric)
# here we load it in again