LogOddsFusion#
- class scikitplot.corpus.LogOddsFusion(base_rate, weights=(), default_weight=1.0, clip=1e-06, top_k=None)[source]#
Pool calibrated legs as log-odds evidence into probabilities of relevance.
- Parameters:
- base_ratefloat
Prior probability of relevance for the fused population, in
(0, 1). It shifts every log-odds equally, so it changes the probabilities but never the order. Required: there is no neutral default.- weightsmapping of str to float, optional
Weight per leg name; finite and non-negative; 0 removes the leg.
- default_weightfloat, default=1.0
Weight of a leg
weightsdoes not name.- clipfloat, default=1e-6
Probabilities are clipped to
[clip, 1 - clip]before the logit; in(0, 0.5).- top_kint or None, default=None
Number of items to return;
Nonereturns all.
- Raises:
- TypeError, ValueError
For a parameter outside its domain.
- Parameters:
Examples
>>> class Fitted: # stands in for a fitted ScoreCalibrator ... fitted, prevalence_ = True, 0.5 ... ... def predict_proba(self, scores): ... return [min(max(s, 0.0), 1.0) for s in scores] >>> fusion = LogOddsFusion(base_rate=0.5) >>> result = fusion.fuse( ... [ ... ("lexical", [("A", 0.9), ("B", 0.6)], Fitted()), ... ("dense", [("B", 0.8), ("C", 0.7)], Fitted()), ... ] ... ) >>> [item.key for item in result.items] ['A', 'B', 'C'] >>> round(result.items[1].probability, 4) # odds 1.5 * 4 = 6 0.8571
- fuse(legs)[source]#
Fuse calibrated legs.
- Parameters:
- legsiterable of (str, iterable of (str, float), calibrator)
Each leg’s name, its
(key, raw score)hits best first, and the fitted calibrator for that leg’s scores.
- Returns:
- LogOddsFusionResult
Items and evidence diagnostics.
- Raises:
- TypeError
For a malformed leg, a non-
strkey or name, a non-numeric score, or a calibrator without the required contract.- ValueError
For an empty key, a non-finite score, an unfitted calibrator, or a calibrated probability outside
[0, 1].
- Parameters:
legs (Iterable[tuple[str, Iterable[tuple[str, float]], Any]])
- Return type: