pyAgrum.lib.explain

The purpose of pyAgrum.lib.explain is to give tools to explain and interpret the structure and parameters of a Bayesian network.

Dealing with independence

pyAgrum.lib.explain.independenceListForPairs(bn)

returns a list of triples (i,j,k) for each non arc (i,j) such that i is independent of j given k.

Parameters:bn (gum.BayesNet) – the Bayesian Network
Returns:the list of independence found in the structure of BN.
Return type:List[(str,str,List[str])]
pyAgrum.lib.explain.plotIndependenceListForPairs(bn, filename, alphabetic=False)

plot the p-value of the chi2 test of a (as simple as possible) independence proposition for every non arc.

Parameters:
  • bn (gum.BayesNet) – the Bayesian network
  • filename (str) – the name of the csv database
  • alphabetic (bool) – if True, the list is alphabetically sorted else it is sorted by the p-value
Returns:

Return type:

matplotlib.Figure

Dealing with mutual information and entropy

pyAgrum.lib.explain.getInformation(bn, evs=None, size=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>)

get a HTML string for a bn annotated with results from inference : entropy and mutual information

Parameters:
  • bn – the BN
  • evs – map of evidence
  • size – size of the graph
  • cmap – colour map used
Returns:

the HTML string

pyAgrum.lib.explain.showInformation(bn, evs=None, size=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>)

show a bn annotated with results from inference : entropy and mutual information

Parameters:
  • bn – the BN
  • evs – map of evidence
  • size – size of the graph
  • cmap – colour map used
Returns:

the graph