API Reference

Frame

class evidencelib.Frame(atoms, *, empty=(), exclusive=False, model='hybrid')[source]

A finite frame of discernment.

The internal representation uses Venn regions. This lets the same proposition algebra represent Shafer’s exclusive DST model, the free DSmT model, and constrained hybrid DSm models.

Parameters:
atom(name)[source]
Parameters:

name (str)

Return type:

Proposition

classmethod dsmt(atoms)[source]

Create the free DSm model where hypotheses may overlap.

Parameters:

atoms (Sequence[str])

Return type:

Frame

classmethod dst(atoms)[source]

Create Shafer’s DST model with mutually exclusive hypotheses.

Parameters:

atoms (Sequence[str])

Return type:

Frame

elements(*, max_count=100000)[source]

Generate the model’s closure under union and intersection.

The result is the power set for DST and the hyper-power set for the free DSm model. DSmT cardinality grows very quickly; pass max_count=None only when you really want the full closure.

Parameters:

max_count (int | None)

Return type:

tuple[Proposition, …]

format(prop)[source]
Parameters:

prop (Proposition)

Return type:

str

classmethod hybrid(atoms, *, empty=(), exclusive=False)[source]

Create a constrained DSm model.

Parameters:
Return type:

Frame

mass(values, **kwargs)[source]
Parameters:

values (Mapping[str | Proposition | Iterable[str], float])

proposition(value)[source]

Coerce a string, proposition, or iterable of atoms into a proposition.

Parameters:

value (str | Proposition | Iterable[str])

Return type:

Proposition

property region_count: int

Number of non-empty disjoint Venn regions in the current model.

symbols(names=None)[source]

Return atom propositions.

names may be omitted to return all frame atoms, or supplied as a whitespace/comma-separated subset.

Parameters:

names (str | None)

Return type:

tuple[Proposition, …]

MassFunction

class evidencelib.MassFunction(frame, values, *, validate=True, tolerance=1e-09)[source]

A basic belief assignment over a frame.

Parameters:
belief(key)[source]
Parameters:

key (str | Proposition | Iterable[str])

Return type:

float

commonality(key)[source]
Parameters:

key (str | Proposition | Iterable[str])

Return type:

float

property conflict: float
conjunctive(*others)[source]

Unnormalized conjunctive rule.

On a free DSm frame this is the classic DSm rule (DSmC). On Shafer’s DST model, contradictory intersections are accumulated on empty.

Parameters:

others (MassFunction)

Return type:

MassFunction

decision()[source]

Return the singleton with the largest pignistic probability.

Return type:

str

dempster(*others)[source]

Dempster’s normalized rule of combination.

Parameters:

others (MassFunction)

Return type:

MassFunction

dsmc(*others)[source]

Alias for the classic conjunctive DSm rule.

Parameters:

others (MassFunction)

Return type:

MassFunction

dsmh(*others)[source]

Hybrid DSm rule for constrained models.

Products whose intersection is non-empty go to that intersection. Products whose intersection is empty are transferred to the union of the involved propositions. If that union is also empty under the model, the mass goes to total ignorance.

Parameters:

others (MassFunction)

Return type:

MassFunction

dubois_prade(*others)[source]

Dubois-Prade style transfer of conflicts to disjunctions.

Parameters:

others (MassFunction)

Return type:

MassFunction

focal()[source]
Return type:

tuple[Proposition, …]

items()[source]
Return type:

tuple[tuple[Proposition, float], …]

mass(key)[source]
Parameters:

key (str | Proposition | Iterable[str])

Return type:

float

normalization_tolerance = 1e-06
normalize()[source]

Normalize a conjunctive result by removing empty-set conflict.

Return type:

MassFunction

pcr5(other)[source]

PCR5 for two sources.

Parameters:

other (MassFunction)

Return type:

MassFunction

pcr6(*others)[source]

PCR6 proportional conflict redistribution for two or more sources.

Parameters:

others (MassFunction)

Return type:

MassFunction

pignistic()[source]

Return pignistic scores for singleton hypotheses.

This is the classical pignistic transformation on DST frames. On free or hybrid DSmT frames, singleton hypotheses can overlap, so the returned event scores are useful for decisions but do not have to sum to one.

Return type:

dict[str, float]

pignistic_regions()[source]

Return a probability distribution over model Venn regions.

Return type:

dict[str, float]

plausibility(key)[source]
Parameters:

key (str | Proposition | Iterable[str])

Return type:

float

smets(*others)[source]

Smets/TBM unnormalized rule, keeping conflict on the empty set.

Parameters:

others (MassFunction)

Return type:

MassFunction

to_dict(*, string_keys=True)[source]

Return the mass assignment as a plain dictionary.

Parameters:

string_keys (bool)

Return type:

dict[str | Proposition, float]

property total_mass: float

Sum of all stored masses.

yager(*others)[source]

Yager’s rule: transfer total conflict to total ignorance.

Parameters:

others (MassFunction)

Return type:

MassFunction

Proposition

class evidencelib.Proposition(frame, regions)[source]

A canonical proposition represented by possible Venn regions.

Users normally create propositions through a evidencelib.Frame and combine them with | for union and & for intersection.

Parameters:
  • frame (Frame)

  • regions (FrozenSet[int])

property cardinality: int

number of non-empty model regions.

Type:

DSm cardinality

frame: Frame
intersects(other)[source]
Parameters:

other (Proposition)

Return type:

bool

property is_empty: bool
regions: FrozenSet[int]
union_atoms()[source]

Return the disjunction of singleton hypotheses involved in this proposition.

Return type:

Proposition

Exceptions

Package-specific exceptions.

exception evidencelib.exceptions.EvidenceLibError[source]

Base exception for evidencelib.

exception evidencelib.exceptions.InvalidMassError[source]

Raised when a mass assignment is invalid.

exception evidencelib.exceptions.TotalConflictError[source]

Raised when normalized combination is undefined due to total conflict.