scikitplot.annoy#
Public Annoy Python API for scikitplot.
Spotify ANNoy [1] (Approximate Nearest Neighbors Oh Yeah).
This package exposes two layers:
Exports:
Low-level C-extension types copied from Spotify’s annoy project:
AnnoyandAnnoyIndex.A high-level, mixin-composed wrapper
Indexthat: - forwards the complete low-level API deterministically, - adds versioned manifest import/export, - provides explicit index I/O names (save_index/load_index), - provides safe Python-object persistence helpers (pickling), - adds optional NumPy export and plotting utilities.
Notes
This module intentionally avoids side effects at import time (no implicit NumPy or matplotlib imports).
See also
scikitplot.cexternals._annoyLow-level C-extension backend.
scikitplot.annoy.IndexHigh-level wrapper composed from mixins.
References
Examples
>>> import random
>>> random.seed(0)
>>> # from annoy import AnnoyIndex
>>> from scikitplot.cexternals._annoy import Annoy, AnnoyIndex
>>> from scikitplot.annoy import Annoy, AnnoyIndex, Index
>>> f = 40 # vector dimensionality
>>> t = Index(f, "angular") # same constructor as the low-level backend
>>> t.add_item(0, [1] * f)
>>> t.build(10) # Build 10 trees
>>> t.get_nns_by_item(0, 1) # Find nearest neighbor
User guide. See the ANNoy Vector Database (Approximate Nearest Neighbors) section for further details.
ANNoy (Approximate Nearest Neighbors Oh Yeah)#
Compiled with GCC/Clang. |
|
High-level ANNoy index composed from mixins. |
ANNoy Index Mixins#
Compression used for |
|
Mixin adding explicit Annoy-native persistence helpers. |
|
Mixin that exports and restores index metadata. |
|
NumPy / SciPy / pandas interoperability for Annoy-like indexes. |
|
Mixin adding pickle support. |
|
Persistence strategy used by |
|
Mixin that adds convenient plotting methods to high-level Annoy wrappers. |
|
User-facing neighbor queries for Annoy-like backends. |