# a function to show results on decision nodes T and Ddefshow_decisions(ie):gnb.flow.row(ie.optimalDecision("Testing"),ie.optimalDecision("Drilling"),f"$${ie.MEU()['mean']:5.3f}\\ (stdev : {math.sqrt(ie.MEU()['variance']):5.3f})$$",captions=["Strategy for T","Strategy for D","MEU and its standard deviation"])gnb.flow.row(ie.posterior("Testing"),ie.posteriorUtility("Testing"),ie.posterior("Drilling"),ie.posteriorUtility("Drilling"),captions=["Final decision for Testing","Final reward for Testing","Final decision for Drilling","Final reward for Drilling"])ie=gum.ShaferShenoyLIMIDInference(oil)display(HTML("<h2>Inference in the LIMID optimizing the decisions nodes</h2>"))ie.makeInference()show_decisions(ie)
Inference in the LIMID optimizing the decisions nodes
Testing
Yes
No
1.0000
0.0000
Strategy for T
Drilling
TestResult
Yes
No
closed
1.0000
0.0000
open
1.0000
0.0000
diffuse
0.0000
1.0000
Strategy for D
$$22.500\ (stdev : 87.457)$$
MEU and its standard deviation
Testing
Yes
No
1.0000
0.0000
Final decision for Testing
Testing
Yes
No
22.5000
20.0000
Final reward for Testing
Drilling
Yes
No
0.5900
0.4100
Final decision for Drilling
Drilling
Yes
No
45.0847
-10.0000
Final reward for Drilling
Graphical inference with evidence and targets (developped nodes)
The default inference for influence diagram actually an inference for LIMIDs. In order to use it for classical (and solvable) influence diagram, do not forget to add the sequence of decision nodes using addNoForgettingAssumption.
Many visual options can be changed when displaing an inference (especially for influence diagrams)
In [17]:
# do not show inference timegum.config["notebook","show_inference_time"]=False# more digits for probabilitiesgum.config["notebook","histogram_horizontal_visible_digits"]=3gnb.showInference(infdiag,engine=ie,size="7!")
In [18]:
# specificic for influence diagram :# more digits for utilitiesgum.config["influenceDiagram","utility_visible_digits"]=5# disabling stdev for utility and MEUgum.config["influenceDiagram","utility_show_stdev"]=False# showing loss (=-utility) and mEL (minimum Expected Loss) instead of MEUgum.config["influenceDiagram","utility_show_loss"]=Truegnb.showInference(infdiag,engine=ie,size="7!")
In [19]:
# visual changes for influence diagram and inferencegum.config.reset()gum.config.push()# keep the current stategum.config['notebook','graph_rankdir']='LR'gnb.sideBySide(infdiag,gnb.getInference(infdiag,engine=ie,targets=["Decision1","Chance3"]))
# more visual changes for influence diagram and inferencegum.config.pop()# back to the last state#shape (https://graphviz.org/doc/info/shapes.html)gum.config["influenceDiagram","chance_shape"]="cylinder"gum.config["influenceDiagram","utility_shape"]="star"gum.config["influenceDiagram","decision_shape"]="box3d"#colorsgum.config["influenceDiagram","default_chance_bgcolor"]="green"gum.config["influenceDiagram","default_utility_bgcolor"]="MediumVioletRed"gum.config["influenceDiagram","default_decision_bgcolor"]="DarkSalmon"gum.config["influenceDiagram","utility_show_stdev"]=Falsegnb.sideBySide(infdiag,gnb.getInference(infdiag,engine=ie,targets=["Decision1","Chance3"]))