Skip to content

Visualizing Bayesian Networks #3

Open
@LuisOB33

Description

@LuisOB33

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions