annoy (mmap) with examples#

An example showing the annoy function.

# Authors: Spotify AB
# SPDX-License-Identifier: Apache-2.0

from annoy import AnnoyIndex

from scikitplot.cexternals.annoy import AnnoyIndex
a = AnnoyIndex(3, 'angular')
a.add_item(0, [1, 0, 0])
a.add_item(1, [0, 1, 0])
a.add_item(2, [0, 0, 1])
a.build(-1)
a.save('test.tree')
True
b = AnnoyIndex(3, 'angular')
b.load('test.tree')
True
print(b.get_nns_by_item(0, 100))
print(b.get_nns_by_vector([1.0, 0.5, 0.5], 100))
[0, 1, 2]
[0, 1, 2]

Tags: model-type: classification model-workflow: impute plot-type: bar level: beginner purpose: showcase

Total running time of the script: (0 minutes 0.030 seconds)

Related examples

annoy (simple) with examples

annoy (simple) with examples

annoy (precision) with examples

annoy (precision) with examples

annoy impute with examples

annoy impute with examples

Visualkeras: Spam Classification Conv1D Dense Example

Visualkeras: Spam Classification Conv1D Dense Example

Gallery generated by Sphinx-Gallery