ProbabilityFusion#
- class scikitplot.corpus.ProbabilityFusion(policy, calibrators, scope=None)[source]#
Opt-in probability fusion for hybrid search: a policy and a calibrator per leg.
- Parameters:
- policyLogOddsFusion
Weights, base rate and clipping. A leg runs only if its weight is above 0.
- calibratorsmapping of str to calibrator
Fitted calibrator for each leg that runs, keyed by
"lexical"(BM25 scores) and"dense"(cosine similarity). Each must be fitted on the scores that leg produces for the hybrid candidate pool:3 * top_khits per leg.- scopeSecurityFilter or None, default=None
The scope the lexical calibrator was fitted under, or None for an unscoped index. When the lexical leg runs, hybrid search fuses only on an index bound to a scope with the same
SecurityFilter.digest(None: an index with no scope).
- Raises:
- TypeError
If
policyis not aLogOddsFusion,calibratorsis not a mapping, a calibrator lacks the contract, orscopeis not aSecurityFilteror None.- ValueError
For an unknown leg name, a running leg without a calibrator, an unfitted calibrator, or no running leg.
- Parameters:
policy (LogOddsFusion)
scope (SecurityFilter | None)
Notes
User. Pass it as
RetrievalConfig(match_mode="hybrid", probability_fusion=...); hits then carryscore= the fused probability of relevance andnative_metric="logodds_probability".BM25 document count, document frequencies and average length are computed over the documents a scope admits, so the same document scores differently under another scope. For a scoped index, fit the lexical calibrator on that index’s scores and pass its
SecurityFilterasscope; any other scope, or none, is refused with both digests named. Cosine similarity does not depend on the scope, so a dense-only fusion (lexical weight 0) runs under any scope.Developer. The scope is matched by digest, never by label: two filters with one label are two scopes.
- policy: LogOddsFusion[source]#
- require_scope(scope)[source]#
Refuse an index scope the lexical calibrator was not fitted under.
- Parameters:
- scopeSecurityFilter or None
The scope the index is bound to; None for an unscoped index.
- Raises:
- ValueError
If the lexical leg runs and the digests differ, naming both.
- Parameters:
scope (SecurityFilter | None)
- Return type:
None
- scope: SecurityFilter | None = None#