lib.image.exportInference
- pyagrum.lib.image.exportInference(model, filename=None, **kwargs)
the graphical representation of an inference in a notebook
- Parameters:
model (
pyAgrum:GraphicalModel) – the model in which to infer (pyagrum.BayesNet,pyagrum.MarkovRandomFieldorpyagrum.InfluenceDiagram)filename (
str) – the name of the resulting file (suffix in [‘pdf’, ‘png’, ‘ps’]). If filename is None, the result is a np.array ready to be used with imshow().engine (
pyagrum.BNInference | pyagrum.MRFInference | pyagrum.CNInference | pyagrum.IDInference) – inference algorithm used. If None,pyagrum.LazyPropagationwill be used for BayesNet,pyagrum.ShaferShenoyMRFInferenceforpyagrum.MarkovRandomFieldandpyagrum.ShaferShenoyLIMIDInferenceforpyagrum.InfluenceDiagram.evs (
dict[str,int | str]) – map of evidencetargets (
set[int | str]) – set of targetssize (
str) – size of the rendered graphnodeColor (
dict[int,float]) – a nodeMap of values (between 0 and 1) to be shown as color of nodes (with special colors for 0 and 1)factorColor (
dict[int,float]) – a nodeMap of values (between 0 and 1) to be shown as color of factors (in MarkovRandomField representation)arcWidth (
dict[(int,int),float]) – a arcMap of values to be shown as width of arcsarcColor (
dict[(int,int),float]) – a arcMap of values (between 0 and 1) to be shown as color of arcscmap (
matplotlib.colors.ColorMap) – color map to show the color of nodes and arcscmapArc (
matplotlib.colors.ColorMap) – color map to show the vals of Arcs.graph (
pyagrum.Graph) – only shows nodes that have their id in the graph (and not in the whole BN)view (
str) – graph | factorgraph | None (default) for Markov random field
- Returns:
the desired representation of the inference
- Return type:
str|dot.Dot
Example
import os
import pyagrum as gum
import pyagrum.lib.image as gimg
bn = gum.fastBN("A->B->C")
gimg.exportInference(bn, "inference.png", evs={"A": 1})
os.path.exists("inference.png")
# True