Exemple #1
0
 def test_query_disconnected_components() -> None:
     cbn = CausalBayesianNetwork([("A", "B")])
     cbn.add_cpds(A=RandomCPD(), B=RandomCPD())
     cbn.query(["A"], {}, intervention={
         "B": 0
     })  # the intervention separates A and B into separare components
Exemple #2
0
 def test_valid_context(cbn_3node: CausalBayesianNetwork) -> None:
     with pytest.raises(ValueError):
         cbn_3node.query(["U"], {"S": 0})
Exemple #3
0
 def test_query(cbn_3node: CausalBayesianNetwork) -> None:
     assert cbn_3node.query(["U"], {"D": 2}).values[2] == float(1.0)