VariableElimination.evidenceImpact

VariableElimination.evidenceImpact(target, evs)

Create a pyagrum.Tensor for P(target|evs) (for all instanciation of target and evs)

Parameters:
  • target (int | str) – the id or the name of the target

  • evs (set[int | str] | list[int | str]) – the ids or names of the nodes of evidence

Warning

if some evs are d-separated, they are not included in the Tensor.

Returns:

a Tensor for P(targets|evs)

Return type:

pyagrum.Tensor

Example

import pyagrum as gum

bn = gum.fastBN("A->B->C")
bn.cpt("A").fillWith([0.2, 0.8])
bn.cpt("B").fillWith([0.9, 0.1, 0.3, 0.7])
bn.cpt("C").fillWith([0.6, 0.4, 0.1, 0.9])
ie = gum.VariableElimination(bn)
# P(C | A) for every value of A
print(ie.evidenceImpact("C", {"A"}))
#
#       ║  C                │
# A     ║0        │1        │
# ──────║─────────│─────────│
# 0     ║ 0.5500  │ 0.4500  │
# 1     ║ 0.2500  │ 0.7500  │

Class

VariableElimination