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 inDEFAULT_BACKEND_ORDER. An explicit built-in name is honoured or raises if unavailable. A customVectorIndexBackendsubclass 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; genericindex_kwargswin 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 reportsfallback_reason="<name>_broken") or refused (False). Also passed toAnnoyBackend. An explicitly named backend is never replaced, whatever this says.- **kwargsAny
Compatibility form for generic backend constructor keyword arguments. Conflicting keys between
index_kwargsandkwargsraise.
- Returns:
- VectorIndexBackend
An unbuilt backend instance;
VectorIndexBackend.provenancerecords 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 andallow_fallbackisFalse(aRuntimeError).
- Parameters:
- Return type: