Logo
pyAgrum 1.1.0 on Jupyter

Tutorials

  • ▶ Tutorial
    • ▷ Tutorial
    • ▷ Tutorial2
  • ▶ Examples
    • ▷ Asthma
    • ▷ Kaggle Titanic
    • ▷ Naive Credit Default Modeling
    • ▷ Causality And Learning
    • ▷ Sensitivity Analysis Using Credal Networks
    • ▷ Quasi Continuous
    • ▷ Parameters Learning With Pandas
  • ▶ Models
    • ▷ Influence Diagram
    • ▷ Dynamic Bn
    • ▷ Markov Network
    • ▷ Credal Networks
    • ▷ O3PRM
  • ▶ Learning
    • ▷ Structural Learning
    • ▷ Learning Classifier
    • ▷ Learning And Essential Graphs
    • ▷ Dirichlet Prior And Weigthed Database
    • ▷ Parametric Em
    • ▷ Chi2 And Scores From Bn Learner
  • ▶ Inference
    • ▷ Graphical Inference
    • ▷ Relevance Reasoning
    • ▷ Lazy Propagation Advanced Features
    • ▷ Approximate Inference
    • ▷ Sampling Inference
  • ▶ Classifier
    • ▷ Learning
    • ▷ Discretizer
    • ▷ Compare Classifiers With Sklearn
    • ▷ Cross Validation
    • ▷ Binary And Nary Classifier From Bn
  • ▶ Causality
    • ▷ Tobacco
    • ▷ Simpson Paradox
    • ▷ Multinomial Simpson Paradox
    • ▷ Do Calculus Examples
    • ▷ Counterfactual
  • ▶ Tools
    • ▷ Potentials
    • ▷ Aggregators
    • ▷ Explain
    • ▷ Kl For BNs
    • ▷ Comparing Bn
    • ▷ Colouring And Exporting BNs
    • ▷ Config For PyAgrum
pyAgrum

Creative Commons License
This pyAgrum's notebook is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Probablistic Inference with pyAgrum¶

In this notebook, we will show different basic features for probabilistic inference on Bayesian networks using pyAgrum.

First we need some external modules:

In [1]:
import os 

%matplotlib inline
from pylab import *
import matplotlib.pyplot as plt

Basic inference and display¶

Then we import pyAgrum and the pyAgrum's notebook module, that offers very usefull methods when writting a notebook.

This first example shows how you can load a BayesNet and show it as graph. Note that pyAgrum handles serveral BayesNet file format such as DSL, BIF and UAI.

In [2]:
import pyAgrum as gum
import pyAgrum.lib.notebook as gnb
bn=gum.loadBN("res/alarm.dsl")
gnb.showBN(bn,size="9")
pyAgrum▶Inference▷Graphical InferenceG pyAgrum▶Inference▷Graphical InferenceSAO2 SAO2 pyAgrum▶Inference▷Graphical InferenceCATECHOL CATECHOL pyAgrum▶Inference▷Graphical InferenceSAO2->CATECHOL pyAgrum▶Inference▷Graphical InferenceVENTALV VENTALV pyAgrum▶Inference▷Graphical InferenceARTCO2 ARTCO2 pyAgrum▶Inference▷Graphical InferenceVENTALV->ARTCO2 pyAgrum▶Inference▷Graphical InferencePVSAT PVSAT pyAgrum▶Inference▷Graphical InferenceVENTALV->PVSAT pyAgrum▶Inference▷Graphical InferencePCWP PCWP pyAgrum▶Inference▷Graphical InferenceHR HR pyAgrum▶Inference▷Graphical InferenceHRSAT HRSAT pyAgrum▶Inference▷Graphical InferenceHR->HRSAT pyAgrum▶Inference▷Graphical InferenceHREKG HREKG pyAgrum▶Inference▷Graphical InferenceHR->HREKG pyAgrum▶Inference▷Graphical InferenceHRBP HRBP pyAgrum▶Inference▷Graphical InferenceHR->HRBP pyAgrum▶Inference▷Graphical InferenceCO CO pyAgrum▶Inference▷Graphical InferenceHR->CO pyAgrum▶Inference▷Graphical InferenceMINVOLSET MINVOLSET pyAgrum▶Inference▷Graphical InferenceVENTMACH VENTMACH pyAgrum▶Inference▷Graphical InferenceMINVOLSET->VENTMACH pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS ANAPHYLAXIS pyAgrum▶Inference▷Graphical InferenceTPR TPR pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS->TPR pyAgrum▶Inference▷Graphical InferenceBP BP pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE KINKEDTUBE pyAgrum▶Inference▷Graphical InferencePRESS PRESS pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceVENTLUNG VENTLUNG pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH INSUFFANESTH pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH->CATECHOL pyAgrum▶Inference▷Graphical InferenceDISCONNECT DISCONNECT pyAgrum▶Inference▷Graphical InferenceVENTTUBE VENTTUBE pyAgrum▶Inference▷Graphical InferenceDISCONNECT->VENTTUBE pyAgrum▶Inference▷Graphical InferenceFIO2 FIO2 pyAgrum▶Inference▷Graphical InferenceFIO2->PVSAT pyAgrum▶Inference▷Graphical InferenceARTCO2->CATECHOL pyAgrum▶Inference▷Graphical InferenceEXPCO2 EXPCO2 pyAgrum▶Inference▷Graphical InferenceARTCO2->EXPCO2 pyAgrum▶Inference▷Graphical InferencePAP PAP pyAgrum▶Inference▷Graphical InferenceCATECHOL->HR pyAgrum▶Inference▷Graphical InferencePVSAT->SAO2 pyAgrum▶Inference▷Graphical InferenceINTUBATION INTUBATION pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTALV pyAgrum▶Inference▷Graphical InferenceINTUBATION->PRESS pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTLUNG pyAgrum▶Inference▷Graphical InferenceMINVOL MINVOL pyAgrum▶Inference▷Graphical InferenceINTUBATION->MINVOL pyAgrum▶Inference▷Graphical InferenceSHUNT SHUNT pyAgrum▶Inference▷Graphical InferenceINTUBATION->SHUNT pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS PULMEMBOLUS pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->PAP pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->SHUNT pyAgrum▶Inference▷Graphical InferenceHISTORY HISTORY pyAgrum▶Inference▷Graphical InferenceTPR->BP pyAgrum▶Inference▷Graphical InferenceTPR->CATECHOL pyAgrum▶Inference▷Graphical InferenceVENTMACH->VENTTUBE pyAgrum▶Inference▷Graphical InferenceERRCAUTER ERRCAUTER pyAgrum▶Inference▷Graphical InferenceERRCAUTER->HRSAT pyAgrum▶Inference▷Graphical InferenceERRCAUTER->HREKG pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME->PCWP pyAgrum▶Inference▷Graphical InferenceCVP CVP pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME->CVP pyAgrum▶Inference▷Graphical InferenceVENTLUNG->VENTALV pyAgrum▶Inference▷Graphical InferenceVENTLUNG->EXPCO2 pyAgrum▶Inference▷Graphical InferenceVENTLUNG->MINVOL pyAgrum▶Inference▷Graphical InferenceVENTTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceVENTTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferenceCO->BP pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA HYPOVOLEMIA pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA->LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA->STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceLVFAILURE LVFAILURE pyAgrum▶Inference▷Graphical InferenceLVFAILURE->HISTORY pyAgrum▶Inference▷Graphical InferenceLVFAILURE->LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceLVFAILURE->STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceSHUNT->SAO2 pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT ERRLOWOUTPUT pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT->HRBP pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME->CO

From there, it is easy to get a posterior using an inference engine :

In [3]:
ie=gum.LazyPropagation(bn)
ie.makeInference()
print(ie.posterior(bn.idFromName("CATECHOL")))
  CATECHOL         |
NORMAL   |HIGH     |
---------|---------|
 0.0512  | 0.9488  |

But since we are in notebook, why not use pyAgrum notebook's methods ?

In [4]:
gnb.showPosterior(bn,evs={},target='CATECHOL')
2022-05-13T11:17:41.795065 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/

You may also want to see the graph with some posteriors

In [5]:
# due to matplotlib, format is forced to png.
gnb.showInference(bn,evs={},targets={"VENTALV","CATECHOL","HR","MINVOLSET"},size="11")
pyAgrum▶Inference▷Graphical Inferencestructs Inference in  10.21ms pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE KINKEDTUBE pyAgrum▶Inference▷Graphical InferenceVENTLUNG VENTLUNG pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferencePRESS PRESS pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA HYPOVOLEMIA pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA->STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA->LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceINTUBATION INTUBATION pyAgrum▶Inference▷Graphical InferenceSHUNT SHUNT pyAgrum▶Inference▷Graphical InferenceINTUBATION->SHUNT pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTLUNG pyAgrum▶Inference▷Graphical InferenceMINVOL MINVOL pyAgrum▶Inference▷Graphical InferenceINTUBATION->MINVOL pyAgrum▶Inference▷Graphical InferenceINTUBATION->PRESS pyAgrum▶Inference▷Graphical InferenceVENTALV 2022-05-13T11:17:41.918211 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTALV pyAgrum▶Inference▷Graphical InferenceMINVOLSET 2022-05-13T11:17:41.874815 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceVENTMACH VENTMACH pyAgrum▶Inference▷Graphical InferenceMINVOLSET->VENTMACH pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS PULMEMBOLUS pyAgrum▶Inference▷Graphical InferencePAP PAP pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->PAP pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->SHUNT pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH INSUFFANESTH pyAgrum▶Inference▷Graphical InferenceCATECHOL 2022-05-13T11:17:41.957615 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH->CATECHOL pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT ERRLOWOUTPUT pyAgrum▶Inference▷Graphical InferenceHRBP HRBP pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT->HRBP pyAgrum▶Inference▷Graphical InferenceERRCAUTER ERRCAUTER pyAgrum▶Inference▷Graphical InferenceHRSAT HRSAT pyAgrum▶Inference▷Graphical InferenceERRCAUTER->HRSAT pyAgrum▶Inference▷Graphical InferenceHREKG HREKG pyAgrum▶Inference▷Graphical InferenceERRCAUTER->HREKG pyAgrum▶Inference▷Graphical InferenceFIO2 FIO2 pyAgrum▶Inference▷Graphical InferencePVSAT PVSAT pyAgrum▶Inference▷Graphical InferenceFIO2->PVSAT pyAgrum▶Inference▷Graphical InferenceLVFAILURE LVFAILURE pyAgrum▶Inference▷Graphical InferenceLVFAILURE->STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceLVFAILURE->LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceHISTORY HISTORY pyAgrum▶Inference▷Graphical InferenceLVFAILURE->HISTORY pyAgrum▶Inference▷Graphical InferenceDISCONNECT DISCONNECT pyAgrum▶Inference▷Graphical InferenceVENTTUBE VENTTUBE pyAgrum▶Inference▷Graphical InferenceDISCONNECT->VENTTUBE pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS ANAPHYLAXIS pyAgrum▶Inference▷Graphical InferenceTPR TPR pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS->TPR pyAgrum▶Inference▷Graphical InferenceCO CO pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME->CO pyAgrum▶Inference▷Graphical InferenceTPR->CATECHOL pyAgrum▶Inference▷Graphical InferenceBP BP pyAgrum▶Inference▷Graphical InferenceTPR->BP pyAgrum▶Inference▷Graphical InferencePCWP PCWP pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME->PCWP pyAgrum▶Inference▷Graphical InferenceCVP CVP pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME->CVP pyAgrum▶Inference▷Graphical InferenceVENTMACH->VENTTUBE pyAgrum▶Inference▷Graphical InferenceSAO2 SAO2 pyAgrum▶Inference▷Graphical InferenceSHUNT->SAO2 pyAgrum▶Inference▷Graphical InferenceVENTTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferenceVENTTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceVENTLUNG->MINVOL pyAgrum▶Inference▷Graphical InferenceVENTLUNG->VENTALV pyAgrum▶Inference▷Graphical InferenceEXPCO2 EXPCO2 pyAgrum▶Inference▷Graphical InferenceVENTLUNG->EXPCO2 pyAgrum▶Inference▷Graphical InferenceARTCO2 ARTCO2 pyAgrum▶Inference▷Graphical InferenceVENTALV->ARTCO2 pyAgrum▶Inference▷Graphical InferenceVENTALV->PVSAT pyAgrum▶Inference▷Graphical InferenceARTCO2->EXPCO2 pyAgrum▶Inference▷Graphical InferenceARTCO2->CATECHOL pyAgrum▶Inference▷Graphical InferencePVSAT->SAO2 pyAgrum▶Inference▷Graphical InferenceSAO2->CATECHOL pyAgrum▶Inference▷Graphical InferenceHR 2022-05-13T11:17:41.995996 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceCATECHOL->HR pyAgrum▶Inference▷Graphical InferenceHR->HRBP pyAgrum▶Inference▷Graphical InferenceHR->HRSAT pyAgrum▶Inference▷Graphical InferenceHR->CO pyAgrum▶Inference▷Graphical InferenceHR->HREKG pyAgrum▶Inference▷Graphical InferenceCO->BP

.. and then observe the impact of evidence :

In [6]:
gnb.showInference(bn,
                  evs={"CO":1,"VENTLUNG":1},
                  targets={"VENTALV",
                           "CATECHOL",
                           "HR",
                           "MINVOLSET",
                           "ANAPHYLAXIS",
                           "STROKEVOLUME",
                           "ERRLOWOUTPUT",
                           "HBR",
                           "PULMEMBOLUS",
                           "HISTORY",
                           "BP",
                           "PRESS",
                           "CO"},
                  size="10")
pyAgrum▶Inference▷Graphical Inferencestructs Inference in   2.94ms pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE KINKEDTUBE pyAgrum▶Inference▷Graphical InferenceVENTLUNG VENTLUNG pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferencePRESS 2022-05-13T11:17:42.665923 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA HYPOVOLEMIA pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME 2022-05-13T11:17:42.587043 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA->STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA->LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceINTUBATION INTUBATION pyAgrum▶Inference▷Graphical InferenceSHUNT SHUNT pyAgrum▶Inference▷Graphical InferenceINTUBATION->SHUNT pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTLUNG pyAgrum▶Inference▷Graphical InferenceMINVOL MINVOL pyAgrum▶Inference▷Graphical InferenceINTUBATION->MINVOL pyAgrum▶Inference▷Graphical InferenceINTUBATION->PRESS pyAgrum▶Inference▷Graphical InferenceVENTALV 2022-05-13T11:17:42.710159 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTALV pyAgrum▶Inference▷Graphical InferenceMINVOLSET 2022-05-13T11:17:42.432784 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceVENTMACH VENTMACH pyAgrum▶Inference▷Graphical InferenceMINVOLSET->VENTMACH pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS 2022-05-13T11:17:42.473690 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferencePAP PAP pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->PAP pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->SHUNT pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH INSUFFANESTH pyAgrum▶Inference▷Graphical InferenceCATECHOL 2022-05-13T11:17:42.749003 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH->CATECHOL pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT 2022-05-13T11:17:42.510499 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceHRBP HRBP pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT->HRBP pyAgrum▶Inference▷Graphical InferenceERRCAUTER ERRCAUTER pyAgrum▶Inference▷Graphical InferenceHRSAT HRSAT pyAgrum▶Inference▷Graphical InferenceERRCAUTER->HRSAT pyAgrum▶Inference▷Graphical InferenceHREKG HREKG pyAgrum▶Inference▷Graphical InferenceERRCAUTER->HREKG pyAgrum▶Inference▷Graphical InferenceFIO2 FIO2 pyAgrum▶Inference▷Graphical InferencePVSAT PVSAT pyAgrum▶Inference▷Graphical InferenceFIO2->PVSAT pyAgrum▶Inference▷Graphical InferenceLVFAILURE LVFAILURE pyAgrum▶Inference▷Graphical InferenceLVFAILURE->STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceLVFAILURE->LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceHISTORY 2022-05-13T11:17:42.624963 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceLVFAILURE->HISTORY pyAgrum▶Inference▷Graphical InferenceDISCONNECT DISCONNECT pyAgrum▶Inference▷Graphical InferenceVENTTUBE VENTTUBE pyAgrum▶Inference▷Graphical InferenceDISCONNECT->VENTTUBE pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS 2022-05-13T11:17:42.546907 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceTPR TPR pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS->TPR pyAgrum▶Inference▷Graphical InferenceCO 2022-05-13T11:17:42.827811 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME->CO pyAgrum▶Inference▷Graphical InferenceTPR->CATECHOL pyAgrum▶Inference▷Graphical InferenceBP 2022-05-13T11:17:42.869145 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceTPR->BP pyAgrum▶Inference▷Graphical InferencePCWP PCWP pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME->PCWP pyAgrum▶Inference▷Graphical InferenceCVP CVP pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME->CVP pyAgrum▶Inference▷Graphical InferenceVENTMACH->VENTTUBE pyAgrum▶Inference▷Graphical InferenceSAO2 SAO2 pyAgrum▶Inference▷Graphical InferenceSHUNT->SAO2 pyAgrum▶Inference▷Graphical InferenceVENTTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferenceVENTTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceVENTLUNG->MINVOL pyAgrum▶Inference▷Graphical InferenceVENTLUNG->VENTALV pyAgrum▶Inference▷Graphical InferenceEXPCO2 EXPCO2 pyAgrum▶Inference▷Graphical InferenceVENTLUNG->EXPCO2 pyAgrum▶Inference▷Graphical InferenceARTCO2 ARTCO2 pyAgrum▶Inference▷Graphical InferenceVENTALV->ARTCO2 pyAgrum▶Inference▷Graphical InferenceVENTALV->PVSAT pyAgrum▶Inference▷Graphical InferenceARTCO2->EXPCO2 pyAgrum▶Inference▷Graphical InferenceARTCO2->CATECHOL pyAgrum▶Inference▷Graphical InferencePVSAT->SAO2 pyAgrum▶Inference▷Graphical InferenceSAO2->CATECHOL pyAgrum▶Inference▷Graphical InferenceHR 2022-05-13T11:17:42.787442 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceCATECHOL->HR pyAgrum▶Inference▷Graphical InferenceHR->HRBP pyAgrum▶Inference▷Graphical InferenceHR->HRSAT pyAgrum▶Inference▷Graphical InferenceHR->CO pyAgrum▶Inference▷Graphical InferenceHR->HREKG pyAgrum▶Inference▷Graphical InferenceCO->BP

You can even compute all posteriors by leaving the targets parameter empty (which is its default value).

In [7]:
gnb.showInference(bn,evs={"CO":1,"VENTLUNG":1},size="14")
pyAgrum▶Inference▷Graphical Inferencestructs Inference in   2.83ms pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE 2022-05-13T11:17:43.334800 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceVENTLUNG 2022-05-13T11:17:44.296791 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferencePRESS 2022-05-13T11:17:44.385967 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA 2022-05-13T11:17:43.376181 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME 2022-05-13T11:17:43.929732 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/ pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA->STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME 2022-05-13T11:17:44.012610 image/svg+xml Matplotlib v3.5.2, https://matplotlib.org/