select_backend#

scikitplot.corpus.select_backend(name='auto', *, index_kwargs=None, annoy_metric='angular', annoy_n_trees=10, annoy_search_k=-1, annoy_impl='auto', annoy_dtype=None, annoy_index_dtype=None, allow_fallback=True, **kwargs)[source]#

Construct an ANN backend by name.

Parameters:
namestr or VectorIndexBackend subclass, optional

"auto" (default) resolves the first available backend in DEFAULT_BACKEND_ORDER. An explicit built-in name is honoured or raises if unavailable. A custom VectorIndexBackend subclass may be supplied directly.

index_kwargsmapping, optional

Generic constructor keyword arguments for the selected backend. New code should prefer this mapping instead of adding backend-specific parameters to RetrievalConfig.

annoy_metric, annoy_n_trees, annoy_search_k, annoy_impl, annoy_dtype, annoy_index_dtype

Backward-compatible Annoy constructor settings. They are merged only when the resolved backend is AnnoyBackend; generic index_kwargs win over default legacy values.

allow_fallbackbool, optional

Under "auto", whether a backend that is installed but cannot be loaded is skipped (True, default; the result reports fallback_reason="<name>_broken") or refused (False). Also passed to AnnoyBackend. An explicitly named backend is never replaced, whatever this says.

**kwargsAny

Compatibility form for generic backend constructor keyword arguments. Conflicting keys between index_kwargs and kwargs raise.

Returns:
VectorIndexBackend

An unbuilt backend instance; VectorIndexBackend.provenance records what was requested and why the result differs.

Raises:
ValueError

If name is not a known backend or "auto".

RuntimeError

If an explicitly named backend is unavailable (the message says whether it is absent or installed but failing to load), or if "auto" finds no available backend (numpy missing).

FallbackRefusedError

If "auto" meets an installed backend that cannot load and allow_fallback is False (a RuntimeError).

Parameters:
  • name (Any)

  • index_kwargs (Mapping[str, Any] | None)

  • annoy_metric (str)

  • annoy_n_trees (int)

  • annoy_search_k (int)

  • annoy_impl (str)

  • annoy_dtype (str | None)

  • annoy_index_dtype (str | None)

  • allow_fallback (bool)

  • kwargs (Any)

Return type:

VectorIndexBackend