lib.notebook.showInference

pyagrum.lib.notebook.showInference(model, **kwargs)

show pydot graph for an inference in a notebook

Parameters:
  • model (pyagrum.GraphicalModel) – the model in which to infer (pyagrum.BayesNet, pyagrum.MarkovRandomField or pyagrum.InfluenceDiagram)

  • engine (pyagrum.BNInference | pyagrum.MRFInference | pyagrum.CNInference | pyagrum.IDInference) – inference algorithm used. If None, pyagrum.LazyPropagation will be used for BayesNet, pyagrum.ShaferShenoyMRFInference for pyagrum.MarkovRandomField and pyagrum.ShaferShenoyLIMIDInference for pyagrum.InfluenceDiagram.

  • evs (dict[int | str, int | str | list[float]]) – map of evidence

  • targets (Set[str]) – set of targets

  • size (string) – size (for graphviz) of the rendered graph

  • nodeColor (dict[str,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[(str,str),float]) – an arcMap of values to be shown as width of arcs

  • arcColor (: dict[(str,str),float]) – a arcMap of values (between 0 and 1) to be shown as color of arcs

  • cmapNode (matplotlib.ColorMap) – map to show the color of nodes and arcs

  • cmapArc (matplotlib.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

Return type:

None

Returns:

the desired representation of the inference

Example

import pyagrum as gum
import pyagrum.lib.notebook as gnb

bn = gum.fastBN("A->B->C")
gnb.showInference(bn, evs={"A": 1}, targets={"C"})