scikitplot.annoy#

Public Annoy Python API for scikitplot.

Spotify ANNoy [0] (Approximate Nearest Neighbors Oh Yeah).

This package exposes two layers:

Exports:

  1. Low-level C-extension types copied from Spotify’s annoy project: Annoy and AnnoyIndex.

  2. A high-level, mixin-composed wrapper Index that: - 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._annoy

Low-level C-extension backend.

scikitplot.annoy.Index

High-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 section for further details.

ANNoy (Approximate Nearest Neighbors Oh Yeah)#

Annoy

Compiled with GCC/Clang.

AnnoyIndex

alias of Annoy

Index

High-level ANNoy index composed from mixins.

ANNoy Index Mixins#

CompressMode

Compression used for "byte" pickling by PickleMixin.

IndexIOMixin

Mixin adding explicit Annoy-native persistence helpers.

MetaMixin

Mixin that exports and restores index metadata.

NDArrayMixin

NumPy / SciPy / pandas interoperability for Annoy-like indexes.

PickleMixin

Mixin adding deterministic pickle support.

PickleMode

Persistence strategy used by PickleMixin.

PlottingMixin

Mixin that adds convenient plotting methods to high-level Annoy wrappers.

VectorOpsMixin

User-facing neighbor queries for Annoy-like backends.