Logo
pyAgrum 1.8.1 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
    • ▷ Bayesian Beta Coin
  • ▶ Models
    • ▷ Influence Diagram
    • ▷ Dynamic Bn
    • ▷ Markov Random Field
    • ▷ 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
  • ▶ Applications
    • ▷ Ipywidgets
  • ▶ Tools
    • ▷ Potentials
    • ▷ Aggregators
    • ▷ Explain
    • ▷ Kl For BNs
    • ▷ Comparing Bn
    • ▷ Colouring And Exporting BNs
    • ▷ Config For PyAgrum
pyAgrum

Probablistic Inference with pyAgrum¶

Creative Commons License aGrUM interactive online version

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 InferenceARTCO2 ARTCO2 pyAgrum▶Inference▷Graphical InferenceEXPCO2 EXPCO2 pyAgrum▶Inference▷Graphical InferenceARTCO2->EXPCO2 pyAgrum▶Inference▷Graphical InferenceCATECHOL CATECHOL pyAgrum▶Inference▷Graphical InferenceARTCO2->CATECHOL pyAgrum▶Inference▷Graphical InferenceHISTORY HISTORY 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 InferenceVENTLUNG VENTLUNG pyAgrum▶Inference▷Graphical InferenceVENTLUNG->EXPCO2 pyAgrum▶Inference▷Graphical InferenceVENTALV VENTALV pyAgrum▶Inference▷Graphical InferenceVENTLUNG->VENTALV pyAgrum▶Inference▷Graphical InferenceMINVOL MINVOL pyAgrum▶Inference▷Graphical InferenceVENTLUNG->MINVOL pyAgrum▶Inference▷Graphical InferenceHRBP HRBP pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT ERRLOWOUTPUT pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT->HRBP pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE KINKEDTUBE pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferencePRESS PRESS pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceMINVOLSET MINVOLSET pyAgrum▶Inference▷Graphical InferenceVENTMACH VENTMACH pyAgrum▶Inference▷Graphical InferenceMINVOLSET->VENTMACH pyAgrum▶Inference▷Graphical InferenceSHUNT SHUNT pyAgrum▶Inference▷Graphical InferenceSAO2 SAO2 pyAgrum▶Inference▷Graphical InferenceSHUNT->SAO2 pyAgrum▶Inference▷Graphical InferenceHR HR pyAgrum▶Inference▷Graphical InferenceHR->HRBP pyAgrum▶Inference▷Graphical InferenceCO CO pyAgrum▶Inference▷Graphical InferenceHR->CO pyAgrum▶Inference▷Graphical InferenceHREKG HREKG pyAgrum▶Inference▷Graphical InferenceHR->HREKG pyAgrum▶Inference▷Graphical InferenceHRSAT HRSAT pyAgrum▶Inference▷Graphical InferenceHR->HRSAT pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME->CO pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS PULMEMBOLUS pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->SHUNT pyAgrum▶Inference▷Graphical InferencePAP PAP pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->PAP pyAgrum▶Inference▷Graphical InferenceVENTTUBE VENTTUBE pyAgrum▶Inference▷Graphical InferenceVENTTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferenceVENTTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceERRCAUTER ERRCAUTER pyAgrum▶Inference▷Graphical InferenceERRCAUTER->HREKG pyAgrum▶Inference▷Graphical InferenceERRCAUTER->HRSAT pyAgrum▶Inference▷Graphical InferencePVSAT PVSAT pyAgrum▶Inference▷Graphical InferencePVSAT->SAO2 pyAgrum▶Inference▷Graphical InferenceVENTMACH->VENTTUBE pyAgrum▶Inference▷Graphical InferenceBP BP pyAgrum▶Inference▷Graphical InferenceCO->BP pyAgrum▶Inference▷Graphical InferenceCATECHOL->HR pyAgrum▶Inference▷Graphical InferenceVENTALV->ARTCO2 pyAgrum▶Inference▷Graphical InferenceVENTALV->PVSAT pyAgrum▶Inference▷Graphical InferenceSAO2->CATECHOL pyAgrum▶Inference▷Graphical InferenceLVFAILURE LVFAILURE pyAgrum▶Inference▷Graphical InferenceLVFAILURE->HISTORY pyAgrum▶Inference▷Graphical InferenceLVFAILURE->STROKEVOLUME pyAgrum▶Inference▷Graphical InferenceLVFAILURE->LVEDVOLUME pyAgrum▶Inference▷Graphical InferenceDISCONNECT DISCONNECT pyAgrum▶Inference▷Graphical InferenceDISCONNECT->VENTTUBE pyAgrum▶Inference▷Graphical InferenceINTUBATION INTUBATION pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTLUNG pyAgrum▶Inference▷Graphical InferenceINTUBATION->SHUNT pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTALV pyAgrum▶Inference▷Graphical InferenceINTUBATION->MINVOL pyAgrum▶Inference▷Graphical InferenceINTUBATION->PRESS pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH INSUFFANESTH pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH->CATECHOL pyAgrum▶Inference▷Graphical InferenceTPR TPR pyAgrum▶Inference▷Graphical InferenceTPR->BP pyAgrum▶Inference▷Graphical InferenceTPR->CATECHOL pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS ANAPHYLAXIS pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS->TPR pyAgrum▶Inference▷Graphical InferenceCVP CVP pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME->CVP pyAgrum▶Inference▷Graphical InferencePCWP PCWP pyAgrum▶Inference▷Graphical InferenceLVEDVOLUME->PCWP pyAgrum▶Inference▷Graphical InferenceFIO2 FIO2 pyAgrum▶Inference▷Graphical InferenceFIO2->PVSAT

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')
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:35.913071</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>

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   3.00ms 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 <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:36.080414</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTALV pyAgrum▶Inference▷Graphical InferenceMINVOLSET <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:36.004355</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> 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 <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:36.145731</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> 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 <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:36.208724</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> 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   8.45ms pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE KINKEDTUBE pyAgrum▶Inference▷Graphical InferenceVENTLUNG VENTLUNG pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferencePRESS <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.127046</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA HYPOVOLEMIA pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.000413</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> 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 <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.197233</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceINTUBATION->VENTALV pyAgrum▶Inference▷Graphical InferenceMINVOLSET <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:36.757508</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceVENTMACH VENTMACH pyAgrum▶Inference▷Graphical InferenceMINVOLSET->VENTMACH pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:36.816022</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferencePAP PAP pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->PAP pyAgrum▶Inference▷Graphical InferencePULMEMBOLUS->SHUNT pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH INSUFFANESTH pyAgrum▶Inference▷Graphical InferenceCATECHOL <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.257133</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceINSUFFANESTH->CATECHOL pyAgrum▶Inference▷Graphical InferenceERRLOWOUTPUT <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:36.873093</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> 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 <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.062162</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceLVFAILURE->HISTORY pyAgrum▶Inference▷Graphical InferenceDISCONNECT DISCONNECT pyAgrum▶Inference▷Graphical InferenceVENTTUBE VENTTUBE pyAgrum▶Inference▷Graphical InferenceDISCONNECT->VENTTUBE pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:36.931478</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceTPR TPR pyAgrum▶Inference▷Graphical InferenceANAPHYLAXIS->TPR pyAgrum▶Inference▷Graphical InferenceCO <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.378837</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME->CO pyAgrum▶Inference▷Graphical InferenceTPR->CATECHOL pyAgrum▶Inference▷Graphical InferenceBP <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.439769</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> 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 <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.317404</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> 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   3.06ms pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:37.984346</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceVENTLUNG <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:39.307615</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->VENTLUNG pyAgrum▶Inference▷Graphical InferencePRESS <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:39.449151</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceKINKEDTUBE->PRESS pyAgrum▶Inference▷Graphical InferenceHYPOVOLEMIA <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:38.041165</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style> pyAgrum▶Inference▷Graphical InferenceSTROKEVOLUME <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <cc:Work> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:date>2023-05-24T15:00:38.744329</dc:date> <dc:format>image/svg+xml</dc:format> <dc:creator> <cc:Agent> <dc:title>Matplotlib v3.7.1, https://matplotlib.org/</dc:title> </cc:Agent> </dc:creator> </cc:Work> </rdf:RDF> <style type="text/css">*{stroke-linejoin: round; stroke-linecap: butt}</style>