erdogant / bnlearn

Python package for Causal Discovery by learning the graphical structure of Bayesian networks. Structure Learning, Parameter Learning, Inferences, Sampling methods.
https://erdogant.github.io/bnlearn
Other
476 stars 46 forks source link

Interactive plot not show bn.plot #47

Closed duducrail closed 1 year ago

duducrail commented 2 years ago

Hi, I'm having problem to visualise interactive plots. I have installed pyvis and I did a test with Game of thrones example from pyvis using Network and works fine. But with bnlearn I got this:

Python 3.7.7 on Mac

interactive 5027F6F9-68DD-47CB-B3F9-DFCA2A286663

erdogant commented 2 years ago

Does it work when you use the Colab example?

Something else that you can try; if you use jupyter notebook try to set the notebook parameter to True bn.plot(model, interactive=True, params_interactive = { 'notebook':True})

duducrail commented 2 years ago

Thanks for your fast response. bn.plot(model, interactive=True, params_interactive = { 'notebook':True}) - didn't work. And when I tried to open Colab example gave this issues:

85CD5D0D-E8DD-4D4E-8ADE-7F0EDB1BD549

01921211-B139-4FAB-BF83-21CA012DB4C0

erdogant commented 2 years ago

I fixed the issue. Can you try again the colab

duducrail commented 2 years ago

Hi erdogant, sorry to bother again. But the colab example also didn't work. I'm putting the Game of thrones example that is working.

716DD893-0AFD-48BB-8DB6-A3047FDF8D83

A0026DFB-58C0-4F9A-8D75-86E6B5B81BC0

With colab example I got this blank on the interactive plot. Maybe is something on my side. I'll try to investigate more as well. Thanks for now. If you have any more things I can try, please I'd like to hear.

AA03FCDC-D7B0-4997-85B0-FEBBD02E77D4

erdogant commented 2 years ago

thanks, this example is useful, I will look into it!

erdogant commented 2 years ago

I compared your working code with that in bnlearn and I created a few changed that -may-can-help but Im not sure because I could not create a not-working-version on my machine.

First update to the latest version with:

pip install -U bnlearn
import bnlearn as bn
# print(bn.__version__)
# Should be >= 0.5.2

I created a small example, can you try whether this works?

# Example dataset
source=['Cloudy','Cloudy','Sprinkler','Rain']
target=['Sprinkler','Rain','Wet_Grass','Wet_Grass']

# Make DAG
DAG = bn.make_DAG(list(zip(source, target)), verbose=0)
# Make plot
bn.plot(DAG, interactive=True)
erdogant commented 2 years ago

Re-open if this still is an issue.

duducrail commented 2 years ago

Hi, sorry for the late reply. Still didn't work. Got this blank plot.

9AFBA8CC-742B-4314-8AB9-96C4751BD9EE

erdogant commented 1 year ago

I added the cdn resources, which can now be changed depending whether jupyter notebook/ Colab etc. It fixes the issues of blank plots in colab and on my machine.

Update to the latest version for this fix.

erdogant commented 1 year ago

I am closing this issue. Reopen if it does not work.