-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
KeyError on call to bn.parameter_learning.fit #105
Comments
I get the same error on the 'asian' example here, https://erdogant.github.io/bnlearn/pages/html/Examples.html import bnlearn as bn Load asia DAGmodel_true = bn.import_DAG('asia') plot ground truthG = bn.plot(model_true) KeyError Traceback (most recent call last) File C:\ProgramData\miniconda3\envs\ml\Lib\site-packages\bnlearn\bnlearn.py:1289, in plot(model, pos, scale, interactive, title, node_color, node_size, node_properties, edge_properties, edge_labels, params_interactive, params_static, verbose) KeyError: 'config' When I look at model_true.keys() it shows dict_keys(['model', 'adjmat']) Thank you for your help. |
Thanks for the issue. It should be fixed now. The bug was checking a key in a dict that did not exist. |
Thank you, that worked. I am now getting a warning on G = bn.plot(model_true) [bnlearn] >Set node properties. I did install graphviz on my computer and put it in the path for all users, and it says it is installed on pip. If you don't know why, no big deal, but trying to get the nice graphs that you have. Thank you for your help. |
To plot graphviz use this:
ps. I did find another issue related to your previous question. The latest version is now 0.10.2. Best to update again. |
Thank you. When using bn_plot_graphviz(model_true) it downloaded graphviz again and installed it in my appdata even though it is in the path of my environment variables. Now it says: [datazets] >INFO> System found: windows but won't plot anything. |
The output is a dotgraph now; you need to open it somehow. Some IDE do open it automatically though.
|
If I do this G = bn.plot_graphviz(model_true) and then this G.view() it makes a pdf in the working directory and shows it. Thank you. |
I had a key error occur on the following call to bnlearn:
model = bn.parameter_learning.fit(DAG, df_discrete)
KeyError Traceback (most recent call last)
Cell In[24], line 1
----> 1 model = bn.parameter_learning.fit(DAG, df_discrete)
File C:\ProgramData\miniconda3\envs\ml\Lib\site-packages\bnlearn\parameter_learning.py:118, in fit(model, df, methodtype, scoretype, smooth, n_jobs, verbose)
115 independence_test = model.get('independence_test', None)
117 # Automatically set methodtype to DBN
--> 118 if str(model['config'].get('method')).lower()=='dbn':
119 config['method'] = 'DBN'
120 if verbose>=3: print('[bnlearn] >Methodtype is set to DynamicBayesianNetwork (DBN)')
KeyError: 'config'
It worked last spring when I presented it to my class, but now I am receiving the error.
Please help and thank you.
The text was updated successfully, but these errors were encountered: