Closed quantitative-ecologist closed 4 months ago
Thank you for this clear explanation! Im going to dig into it.
Thank you for your patience. In specific cases, the weights for the edges were indeed not updated. I fixed that issue now.
Update to the latest version with pip install -U bnlearn
Can you confirm whether this also works for you?
Closing this! Let me know if something is still off.
Hello,
Thank you for the bnlearn library for Python!
I have been playing with it for a couple of weeks and found some strange behaviour with the plot function that makes me question if it's a bug.
Here is an example :
1. I have learned the parameters of a DAG and then applied the "g_sq" independence test.
DAG = bn.independence_test(DAG, train_df, test = "g_sq", prune = False)
Printing the output, I get this :
print(DAG["independence_test"])
2. Plotting the DAG
3. Problem
Given that the independence test value for this edge is smaller compared to some of the larger ones :
then why is the edge returned on the plot much thicker (hunting type --> hunting success)?
then why is the edge weight is so small on the plot?
4. Attempted solution
Given my suspicions that the plot method does not use the proper weights, I coded my own plot using networkx and matplotlib. Here is my code. It seems that my solution uses the proper weights.
Comparing with the Titanic example
I tried to reproduce my problem using the exact same code provided for the Titanic example, and it seems like this strange behaviour also occurs. Here are my outputs :
As you can see, the edge between SibSp --> Parch should be much larger, given that the independence test results are :
Any help would be greatly appreciated.
Thank you very much!