Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualizing Bayesian Networks #3

Open
LuisOB33 opened this issue Feb 10, 2023 · 0 comments
Open

Visualizing Bayesian Networks #3

LuisOB33 opened this issue Feb 10, 2023 · 0 comments

Comments

@LuisOB33
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant