From 896052f8807a3c5ad90924f9308e077cce5446b9 Mon Sep 17 00:00:00 2001 From: erdogant Date: Wed, 23 Oct 2024 23:12:12 +0200 Subject: [PATCH] bugfix issue105 DBN error --- bnlearn/bnlearn.py | 4 ++-- bnlearn/examples.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bnlearn/bnlearn.py b/bnlearn/bnlearn.py index 2df729e..afb7b10 100644 --- a/bnlearn/bnlearn.py +++ b/bnlearn/bnlearn.py @@ -1139,7 +1139,7 @@ def plot_graphviz(model, if model['adjmat'].sum().sum()==0: if verbose>=3: print('[bnlearn]> Nothing to plot because no edges are present between nodes. ') return None - if model['config']['method']=='DBN': + if model.get('config', {}).get('method') == 'DBN': if verbose>=3: print('[bnlearn]> DynamicBayesianNetwork (DBN) can not be plot with Graphviz.') return None @@ -1286,7 +1286,7 @@ def plot(model, if verbose>=3: print('[bnlearn]> Nothing to plot because no edges are present between nodes. ') return None - if model['config']['method']=='DBN' and interactive: + if model.get('config', {}).get('method') == 'DBN' and interactive: if verbose>=3: print('[bnlearn]> DynamicBayesianNetwork (DBN) can not be plot with Graphviz.') return None diff --git a/bnlearn/examples.py b/bnlearn/examples.py index 0e488a7..33b572a 100644 --- a/bnlearn/examples.py +++ b/bnlearn/examples.py @@ -1,3 +1,11 @@ +#%% +import bnlearn as bn +model = bn.import_DAG('asia') +G = bn.plot(model) + + + + # %% Impute categorical values import bnlearn as bn import pandas as pd