def time_pathfinder_read(self): get_example_model('pathfinder')
def time_munin_read(self): get_example_model('munin')
def time_asia_read(self): get_example_model('asia')
#Step 1: Generate some data # Use the alarm model to generate data from it. from pgmpy.utils import get_example_model from pgmpy.sampling import BayesianModelSampling alarm_model = get_example_model('alarm') samples = BayesianModelSampling(alarm_model).forward_sample(size=int(1e5)) print(samples.head()) #Step 2: Define a model structure # Defining the Bayesian Model structure from pgmpy.models import BayesianModel model_struct = BayesianModel(ebunch=alarm_model.edges()) print(model_struct.nodes()) #Step 3: Learning the model parameters # Fitting the model using Maximum Likelihood Estimator from pgmpy.estimators import MaximumLikelihoodEstimator mle = MaximumLikelihoodEstimator(model=model_struct, data=samples) # Estimating the CPD for a single node. print(mle.estimate_cpd(node='FIO2')) print(mle.estimate_cpd(node='CVP')) # Estimating CPDs for all the nodes in the model
def setup(self): self.alarm = get_example_model('alarm') self.munin = get_example_model('munin')
def setup(self): self.alarm = get_example_model('alarm')