scikitplot.annoy#

scikitplot.annoy#

Public Annoy Python API for scikitplot.

Spotify ANNoy [1] (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,

  • decides how many threads build an index from one rule (threads_info, SKPLT_ANNOY_THREADS).

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

ANNoy (cython based scikitplot/annoy/_annoy)#

ANNoy (Approximate Nearest Neighbors Oh Yeah)

Class inheritance

Inheritance diagram of _annoy.Index

_annoy.Index

Annoy Approximate Nearest Neighbors Index.

ANNoy (cpp based scikitplot/cexternals/_annoy)#

ANNoy (Approximate Nearest Neighbors Oh Yeah)

Class inheritance

Inheritance diagram of Index

Annoy

Compiled with GCC/Clang.

AnnoyIndex

Index

High-level ANNoy index composed from mixins.

threads_info

Describe what decides the number of threads in this process.

ANNoy (cpp based Index Mixins)#

CompressMode

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 pickle support.

PickleMode

PlottingMixin

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

VectorOpsMixin

User-facing neighbor queries for Annoy-like backends.