erdogant / bnlearn

Python library for learning the graphical structure of Bayesian networks, parameter learning, inference and sampling methods.
https://erdogant.github.io/bnlearn
Other
463 stars 45 forks source link

Save network plot as image #65

Closed sbhadana closed 1 year ago

sbhadana commented 1 year ago

After creating the network, bn.plot(model) displays the network, but how to save it as image without using an IDE. q = bn.plot(model) return a dict not a fig object.

image

Is there any functionality which I am missing?

erdogant commented 1 year ago

Good point. This was not returned but now it is!

Update to the latest version with: pip install -U bnlearn

Example:

import bnlearn as bn
model = bn.import_DAG('sprinkler', CPD=True)
df = bn.sampling(model, n=1000, methodtype='bayes')
fig = bn.plot(model)
fig['ax']

# Toggle with the visible status
fig = bn.plot(model, params_static={'visible': True})