Skip to content

Commit

Permalink
Add support for loading XMLBIF models in load_model function
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoFasulo committed Mar 9, 2024
1 parent a8e0dde commit 4d7bffe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 242 deletions.
7 changes: 4 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import numpy as np
import pandas as pd
from pgmpy.readwrite.PomdpX import PomdpXReader
from pgmpy.readwrite.XMLBIF import XMLBIFReader
from pgmpy.readwrite.BIF import BIFReader
from pgmpy.inference import VariableElimination
Expand All @@ -15,8 +16,8 @@ def load_dataset(data: pd.DataFrame):
@st.cache_data
def load_model(model_type='bif'):
if model_type == 'bif':
return BIFReader(f'model{os.sep}heart_disease_model.bif').get_model()
else:
return BIFReader(path=f'model{os.sep}heart_disease_model.bif', n_jobs=1).get_model()
elif model_type == 'xml':
return XMLBIFReader(f'model{os.sep}heart_disease_model.xml').get_model()


Expand Down Expand Up @@ -49,7 +50,7 @@ def exact_inference(model, variables, evidence):
# with st.expander('About Bayesian Networks')

df = load_dataset(data=f'data{os.sep}heart_cleaned.csv')
model = load_model()
model = load_model(model_type='bif')
probs = np.array([])

LEFT, RIGHT = st.columns(2)
Expand Down
Loading

0 comments on commit 4d7bffe

Please sign in to comment.