PyBNesian
PyBNesian copied to clipboard
Visualizing Bayesian Networks
For those interested in visualizing Graph or GaussianNetwork objects, I have developed this code:
!pip install networkx
import networkx as nx
def visualizeGraph(bnGraph):
G = nx.DiGraph()
G.add_edges_from(bnGraph.arcs(), weight=1)
return nx.draw(G, with_labels=True, node_size=1500, node_color='b', alpha=0.6)
gbn = bn.GaussianNetwork(['a', 'b', 'c', 'd'], [('a', 'c'), ('b', 'c'), ('c', 'd')])
graph = gbn.graph()
visualizeGraph(gbn)
visualizeGraph(graph)
The visualizeGraph function could be modified following the networkx documentation as to achieve different results